Mock/Mocks.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
function Get-ADComputer { [pscustomobject]@{ DotsHostname = 'dc01.ad.contoso.com' DNSHostname = 'dc01.ad.contoso.com' Name = 'dc01' OperatingSystem = 'Windows Server 2016 Datacenter' OperatingSystemVersion = '10.0 (14393)' CanonicalName = 'ad.contoso.com/tier 0/computers/dc01' lastlogondate = [datetime]::Now }, [pscustomobject]@{ DotsHostname = 'dc02.ad.contoso.com' DNSHostname = 'dc02.ad.contoso.com' Name = 'dc02' OperatingSystem = 'Windows Server 2016 Datacenter' OperatingSystemVersion = '10.0 (14393)' CanonicalName = 'ad.contoso.com/tier 0/computers/dc02' lastlogondate = [datetime]::Now }, [pscustomobject]@{ DotsHostname = 'cfgmgmt01.ad.contoso.com' DNSHostname = 'cfgmgmt01.ad.contoso.com' Name = 'cfgmgmt01' OperatingSystem = 'Windows Server 2016 Datacenter' OperatingSystemVersion = '10.0 (14393)' CanonicalName = 'ad.contoso.com/tier 0/computers/cfgmgmt01' lastlogondate = [datetime]::Now }, [pscustomobject]@{ DotsHostname = 'psbot01.ad.contoso.com' DNSHostname = 'psbot01.ad.contoso.com' Name = 'psbot01' OperatingSystem = 'Windows Server 2016 Datacenter' OperatingSystemVersion = '10.0 (14393)' CanonicalName = 'ad.contoso.com/tier 1/computers/psbot01' lastlogondate = [datetime]::Now } } function Get-PDBNode { [pscustomobject]@{ certname = 'dc01.ad.contoso.com' 'facts-timestamp' = '2018-02-22T17:00:51.287Z' }, [pscustomobject]@{ certname = 'dc02.ad.contoso.com' 'facts-timestamp' = '2018-02-22T17:00:51.287Z' }, [pscustomobject]@{ certname = 'cfgmgmt01.ad.contoso.com' 'facts-timestamp' = '2018-02-22T17:00:51.287Z' }, [pscustomobject]@{ certname = 'gitlab01.ad.contoso.com' 'facts-timestamp' = '2018-02-22T17:00:51.287Z' }, [pscustomobject]@{ certname = 'psbot01.ad.contoso.com' 'facts-timestamp' = '2018-02-22T17:00:51.287Z' } } function Get-PDBNodeFact { param($Certname) switch($Certname) { 'dc01.ad.contoso.com' { [pscustomobject]@{ DotsHostname = 'dc01.ad.contoso.com' certname = 'dc01.ad.contoso.com' environment = 'production' puppet_classes = '["default", "nagios::base", "nagios::client", "profiles::base", "profiles::service::nxlog", "roles::service::msadds"]' } } 'dc02.ad.contoso.com' { [pscustomobject]@{ DotsHostname = 'dc02.ad.contoso.com' certname = 'dc02.ad.contoso.com' environment = 'wframe/winlogbeat' puppet_classes = '["default", "nagios::base", "nagios::client", "profiles::base", "profiles::service::winlogbeat", "roles::service::msadds"]' } } 'cfgmgmt01.ad.contoso.com' { [pscustomobject]@{ DotsHostname = 'cfgmgmt01.ad.contoso.com' certname = 'cfgmgmt01.ad.contoso.com' environment = 'production' puppet_classes = '["default", "nagios::base", "nagios::client", "profiles::base", "profiles::service::nxlog"]' } } 'gitlab01.ad.contoso.com' { [pscustomobject]@{ DotsHostname = 'gitlab01.ad.contoso.com' certname = 'gitlab01.ad.contoso.com' environment = 'production' puppet_classes = '["default", "nagios::base", "nagios::client", "profiles::base", "roles::service::gitlab"]' } } 'psbot01.ad.contoso.com' { [pscustomobject]@{ DotsHostname = 'psbot01.ad.contoso.com' certname = 'psbot01.ad.contoso.com' environment = 'production' puppet_classes = '["default", "nagios::base", "nagios::client", "profiles::base", "profiles::service::nxlog", "roles::psbot"]' } } } } function Get-ADUser { [pscustomobject]@{ SamAccountName = 'aboss' userprincipalname = 'aboss@ad.contoso.com' title = 'boss' mail = 'aboss@contoso.com' sid = @{value = 'S-1-5-21-1004336348-1177238915-682003330-00000'} distinguishedname = 'CN=aboss,OU=Domain Users,DC=ad,DC=contoso,DC=com' memberof = @('CN=Domain Users,CN=Users,DC=ad,DC=contoso,DC=com', 'CN=psbot-users,OU=Domain Groups,DC=ad,DC=contoso,DC=com', 'CN=psbot-admins,OU=groups,OU=tier 1,DC=ad,DC=contoso,DC=com') lastlogondate = [datetime]::Now } [pscustomobject]@{ SamAccountName = 'wframe' userprincipalname = 'wframe@ad.contoso.com' title = 'sysadmin' mail = 'wframe@contoso.com' sid = @{value = 'S-1-5-21-1004336348-1177238915-682003330-11111'} distinguishedname = 'CN=wframe,OU=Domain Users,DC=ad,DC=contoso,DC=com' memberof = @('CN=Domain Users,CN=Users,DC=ad,DC=contoso,DC=com', 'CN=psbot-users,OU=Domain Groups,DC=ad,DC=contoso,DC=com', 'CN=psbot-admins,OU=groups,OU=tier 1,DC=ad,DC=contoso,DC=com') lastlogondate = [datetime]::Now }, [pscustomobject]@{ SamAccountName = 'wframet0' userprincipalname = 'wframet0@ad.contoso.com' title = 'sysadmin' mail = '' sid = @{value='S-1-5-21-1004336348-1177238915-682003330-22222'} distinguishedname = 'CN=wframet0,OU=Domain Users,DC=ad,DC=contoso,DC=com' memberof = @('CN=Domain Admins,CN=Users,DC=ad,DC=contoso,DC=com', 'CN=Domain Users,CN=Users,DC=ad,DC=contoso,DC=com') lastlogondate = [datetime]::Now } } function Get-ADGroup { [pscustomobject]@{ SamAccountName = 'Domain Admins' name = 'Domain Admins' distinguishedname = 'CN=Domain Admins,CN=Users,DC=ad,DC=contoso,DC=com' SID = @{value='S-1-5-21-1004336348-1177238915-682003330-512'} }, [pscustomobject]@{ SamAccountName = 'Domain Users' name = 'Domain Users' distinguishedname = 'CN=Domain Users,CN=Users,DC=ad,DC=contoso,DC=com' SID = @{value='S-1-5-21-1004336348-1177238915-682003330-513'} }, [pscustomobject]@{ SamAccountName = 'psbot-users' name = 'psbot-users' distinguishedname = 'CN=psbot-users,OU=Domain Groups,DC=ad,DC=contoso,DC=com' managedby = 'CN=wframe,OU=Domain Users,DC=ad,DC=contoso,DC=com' SID = @{value='S-1-5-21-1004336348-1177238915-682003330-222222'} }, [pscustomobject]@{ SamAccountName = 'psbot-admins' name = 'psbot-admins' distinguishedname = 'CN=psbot-admins,OU=groups,OU=tier 1,DC=ad,DC=contoso,DC=com' managedby = 'CN=wframe,OU=Domain Users,DC=ad,DC=contoso,DC=com' SID = @{value='S-1-5-21-1004336348-1177238915-682003330-333333'} } } function ActiveDirectory\Get-ADObject { param($Identity, $Properties) if($Identity -eq 'CN=wframe,OU=Domain Users,DC=ad,DC=contoso,DC=com') { [pscustomobject]@{ SamAccountName = 'wframe' } } } function Get-ScheduledTasks { [pscustomobject]@{ ComputerName = 'psbot01' Name = 'Watch-PSBot' Path = '\Watch-PSBot' Enabled = $True Action = 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe' Arguments = '-NoProfile -ExecutionPolicy Bypass -WindowStyle Hidden -File "C:\tasks\Watch-PSBot.ps1"' UserId = 'NT AUTHORITY\System' LastRunTime = Get-Date "2018-02-26T21:03:27Z" NextRunTime = Get-Date "2018-02-26T21:13:28Z" Status = 'Ready' Author = 'contoso\wframe' RunLevel = 'HighestAvailable' Description = 'Watch for PSBot presence -ne active' } } function Get-SqlInstance { # Simple: # https://gallery.technet.microsoft.com/scriptcenter/Get-SQLInstance-9a3245a0 # Borrowed from Boe's example data # More complex: # Various dbatools for querying instance info, including https://dbatools.io/functions/get-dbasqlinstanceproperty/ [pscustomobject]@{ ComputerName = 'mssql01' FullName = 'SQLCLU\MSSQLSERVER' Instance = 'MSSQLSERVER' SqlServer = 'SQLCLU' Version = '10.53.6000.34' Splevel = 3 Clustered = $False Installpath = 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL' Datapath = 'D:\MSSQL10_50.MSSQLSERVER\MSSQL' Caption = 'SQL Server 2008 R2' BackupDirectory = 'F:\MSSQL10_50.MSSQLSERVER\MSSQL\Backup' } } function Get-Disk { [pscustomobject]@{ DeviceID = '' ComputerName = '' Path = '' VolumeName = '' SCSITarget = '' SCSIController = '' DataStore = '' Type = '' StorageFormat = '' } } function Get-ServerInfo { [pscustomobject]@{ ComputerName = '' OSInstallDate = '' UACSettings = '' LastBootupTime = '' Manufacturer = '' Model = '' Serial = '' OS = '' OSServicePack = '' PageFileBaseSize = '' PageFileMaxSize = '' PageFileMaxUse = '' IPv6DisabledComponents = '' } } function Get-ServiceInfo { [pscustomobject]@{ ComputerName = '' Name = '' Caption = '' StartName = '' StartMode = '' State = '' PathName = '' DesktopInteract = '' } } |