Providers/Microsoft-ActiveDirectory.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 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 |
$Global:ProviderSetup = @{ ProviderName = 'Microsoft Active Directory' StartupMessage = 'Importing Active Directory Module and Configuration' ModulesToImport = @() WinPSModulesToImport = @('ActiveDirectory') StartupScript = [scriptblock] { <# ## Overview ## Each of the Optimize-VMPowerCLIData functions require a Parameter containg a configuration map. The following maps define a configuration template you can copy to your 'TMD_Files\Config\VMware-vCenter.ps1' file if you wish to make changes. Config Map in that file override the default configuration deployed with the TMD VMware vCenter Provider Package. The intent is to expose a configuration file location where a user can edit each these functions without disrupting the TMD Application code. ## ScriptBlock / ProcessingMaps Consider each of the below ScriptBlocks as a processing map. They are are executed inside of a loop, once for each asset when the object is being Optimized within the Optimize-VMPowerCLIData functions. Each Itteration of the script block exposes an $Item (One for each in the $Data parameter). The usage of the Optimize-VMPowerCLIData command is to provide a configuration map, where each $Item results in an output of an object. The $Item.{properties} can be mapped to a PSObject or HashTable object per the following example: ###################################################### [scriptblock]$ADMaps.Datacenter = { return @{ ## Basic Asset Details id = $Item.Id name = $Item.Name ## Asset Class Details assetDetails = @{ datastore = $Item.ExtensionData.Datastore } ## Asset's Environment Resources assetResources = @{ items = $Item.ExtensionData.items } } } ###################################################### Tip: Convenient way to identify the $Item properties: $Item.PSObject.Properties | Select-Object Name, Value | Clip #> ## Define the Map objects $ADMaps = @{} ## ## Active Directory Processing Maps ## ## Get-ADDomain [scriptblock]$ADMaps.ADDomain = { return [PSCustomObject] @{ AllowedDNSSuffixes = $Item.AllowedDNSSuffixes.Value ChildDomains = $Item.ChildDomains.Value ComputersContainer = $Item.ComputersContainer DeletedObjectsContainer = $Item.DeletedObjectsContainer DistinguishedName = $Item.DistinguishedName DNSRoot = $Item.DNSRoot DomainControllersContainer = $Item.DomainControllersContainer DomainMode = $Item.DomainMode DomainSID = $Item.DomainSID.Value ForeignSecurityPrincipalsContainer = $Item.ForeignSecurityPrincipalsContainer Forest = $Item.Forest InfrastructureMaster = $Item.InfrastructureMaster LastLogonReplicationInterval = $Item.LastLogonReplicationInterval LinkedGroupPolicyObjects = $Item.LinkedGroupPolicyObjects LostAndFoundContainer = $Item.LostAndFoundContainer ManagedBy = $Item.ManagedBy Name = $Item.Name NetBIOSName = $Item.NetBIOSName ObjectClass = $Item.ObjectClass ObjectGUID = $Item.ObjectGUID ParentDomain = $Item.ParentDomain PDCEmulator = $Item.PDCEmulator PublicKeyRequiredPasswordRolling = $Item.PublicKeyRequiredPasswordRolling QuotasContainer = $Item.QuotasContainer ReadOnlyReplicaDirectoryServers = $Item.ReadOnlyReplicaDirectoryServers.Value ReplicaDirectoryServers = $Item.ReplicaDirectoryServers.Value RIDMaster = $Item.RIDMaster SubordinateReferences = $Item.SubordinateReferences SystemsContainer = $Item.SystemsContainer UsersContainer = $Item.UsersContainer } } ## Get-ADForest [scriptblock]$ADMaps.ADForest = { return [PSCustomObject] @{ ApplicationPartitions = $Item.ApplicationPartitions CrossForestReferences = $Item.CrossForestReferences DomainNamingMaster = $Item.DomainNamingMaster Domains = $Item.Domains ForestMode = $Item.ForestMode GlobalCatalogs = $Item.GlobalCatalogs Name = $Item.Name PartitionsContainer = $Item.PartitionsContainer RootDomain = $Item.RootDomain SchemaMaster = $Item.SchemaMaster Sites = $Item.Sites SPNSuffixes = $Item.SPNSuffixes UPNSuffixes = $Item.UPNSuffixes } } ## Get-ADDomainController [scriptblock]$ADMaps.ADDomainController = { return [PSCustomObject] @{ ComputerObjectDN = $Item.ComputerObjectDN DefaultPartition = $Item.DefaultPartition Domain = $Item.Domain Enabled = $Item.Enabled Forest = $Item.Forest HostName = $Item.HostName InvocationId = $Item.InvocationId IPv4Address = $Item.IPv4Address IPv6Address = $Item.IPv6Address IsGlobalCatalog = $Item.IsGlobalCatalog IsReadOnly = $Item.IsReadOnly LdapPort = $Item.LdapPort Name = $Item.Name NTDSSettingsObjectDN = $Item.NTDSSettingsObjectDN OperatingSystem = $Item.OperatingSystem OperatingSystemHotfix = $Item.OperatingSystemHotfix OperatingSystemServicePack = $Item.OperatingSystemServicePack OperatingSystemVersion = $Item.OperatingSystemVersion OperationMasterRoles = $Item.OperationMasterRoles Partitions = $Item.Partitions PSShowComputerName = $Item.PSShowComputerName ServerObjectDN = $Item.ServerObjectDN ServerObjectGuid = $Item.ServerObjectGuid Site = $Item.Site SslPort = $Item.SslPort } } ## Get-ADComputer [scriptblock]$ADMaps.ADComputer = { return [PSCustomObject] @{ ## Basic Asset Details id = $Item.Sid.Value name = $Item.Name Description = $Item.Description ## AD Computer Object Details Enabled = $Item.Enabled InstanceType = $Item.InstanceType DistinguishedName = $Item.DistinguishedName SamAccountName = $Item.SamAccountName ObjectCategory = $Item.ObjectCategory ObjectClass = $Item.ObjectClass ObjectGuid = $Item.ObjectGuid.Guid Location = $Item.Location ManagedBy = $Item.ManagedBy ## System Details OperatingSystem = $Item.OperatingSystem OperatingSystemHotfix = $Item.OperatingSystemHotfix OperatingSystemServicePack = $Item.OperatingSystemServicePack OperatingSystemVersion = $Item.OperatingSystemVersion ## Network Details DNSHostName = $Item.DNSHostName IPv4Address = $Item.IPv4Address ## Usage and Memberships LastLogonTimestamp = $Item.lastLogonTimestamp MemberOf = $Item.MemberOf PrimaryGroup = $Item.PrimaryGroup } } ## Get-ADGroup [scriptblock]$ADMaps.ADGroup = { return [PSCustomObject] @{ adminCount = $Item.adminCount CanonicalName = $Item.CanonicalName CN = $Item.CN Created = $Item.Created createTimeStamp = $Item.createTimeStamp Deleted = $Item.Deleted Description = $Item.Description DisplayName = $Item.DisplayName DistinguishedName = $Item.DistinguishedName dSCorePropagationData = $Item.dSCorePropagationData GroupCategory = $Item.GroupCategory GroupScope = $Item.GroupScope groupType = $Item.groupType HomePage = $Item.HomePage instanceType = $Item.instanceType isCriticalSystemObject = $Item.isCriticalSystemObject isDeleted = $Item.isDeleted LastKnownParent = $Item.LastKnownParent ManagedBy = $Item.ManagedBy member = $Item.member MemberOf = $Item.MemberOf Members = $Item.Members Modified = $Item.Modified modifyTimeStamp = $Item.modifyTimeStamp Name = $Item.Name ObjectCategory = $Item.ObjectCategory ObjectClass = $Item.ObjectClass ObjectGUID = $Item.ObjectGUID objectSid = $Item.objectSid.Value ProtectedFromAccidentalDeletion = $Item.ProtectedFromAccidentalDeletion SamAccountName = $Item.SamAccountName sAMAccountType = $Item.sAMAccountType sDRightsEffective = $Item.sDRightsEffective SID = $Item.SID.Value SIDHistory = $Item.SIDHistory systemFlags = $Item.systemFlags uSNChanged = $Item.uSNChanged uSNCreated = $Item.uSNCreated whenChanged = $Item.whenChanged whenCreated = $Item.whenCreated } } ## Get-ADGroupMember [scriptblock]$ADMaps.ADGroupMember = { return [PSCustomObject] @{ distinguishedName = $Item.distinguishedName name = $Item.name objectClass = $Item.objectClass objectGUID = $Item.objectGUID SamAccountName = $Item.SamAccountName SID = $Item.SID.Value } } ## Get-ADUser [scriptblock]$ADMaps.ADUser = { return [PSCustomObject] @{ AccountExpirationDate = $Item.AccountExpirationDate accountExpires = $Item.accountExpires AccountLockoutTime = $Item.AccountLockoutTime AccountNotDelegated = $Item.AccountNotDelegated adminCount = $Item.adminCount AllowReversiblePasswordEncryption = $Item.AllowReversiblePasswordEncryption AuthenticationPolicy = $Item.AuthenticationPolicy AuthenticationPolicySilo = $Item.AuthenticationPolicySilo BadLogonCount = $Item.BadLogonCount badPasswordTime = $Item.badPasswordTime badPwdCount = $Item.badPwdCount CannotChangePassword = $Item.CannotChangePassword CanonicalName = $Item.CanonicalName Certificates = $Item.Certificates City = $Item.City CN = $Item.CN codePage = $Item.codePage Company = $Item.Company CompoundIdentitySupported = $Item.CompoundIdentitySupported Country = $Item.Country countryCode = $Item.countryCode Created = $Item.Created createTimeStamp = $Item.createTimeStamp Deleted = $Item.Deleted Department = $Item.Department Description = $Item.Description DisplayName = $Item.DisplayName DistinguishedName = $Item.DistinguishedName Division = $Item.Division DoesNotRequirePreAuth = $Item.DoesNotRequirePreAuth dSCorePropagationData = $Item.dSCorePropagationData EmailAddress = $Item.EmailAddress EmployeeID = $Item.EmployeeID EmployeeNumber = $Item.EmployeeNumber Enabled = $Item.Enabled Fax = $Item.Fax GivenName = $Item.GivenName HomeDirectory = $Item.HomeDirectory HomedirRequired = $Item.HomedirRequired HomeDrive = $Item.HomeDrive HomePage = $Item.HomePage HomePhone = $Item.HomePhone Initials = $Item.Initials instanceType = $Item.instanceType isCriticalSystemObject = $Item.isCriticalSystemObject isDeleted = $Item.isDeleted KerberosEncryptionType = $Item.KerberosEncryptionType LastBadPasswordAttempt = $Item.LastBadPasswordAttempt LastKnownParent = $Item.LastKnownParent lastLogoff = $Item.lastLogoff lastLogon = $Item.lastLogon LastLogonDate = $Item.LastLogonDate lastLogonTimestamp = $Item.lastLogonTimestamp LockedOut = $Item.LockedOut lockoutTime = $Item.lockoutTime logonCount = $Item.logonCount logonHours = $Item.logonHours LogonWorkstations = $Item.LogonWorkstations Manager = $Item.Manager MemberOf = $Item.MemberOf MNSLogonAccount = $Item.MNSLogonAccount MobilePhone = $Item.MobilePhone Modified = $Item.Modified modifyTimeStamp = $Item.modifyTimeStamp 'msDS-SupportedEncryptionTypes' = $Item.'msDS-SupportedEncryptionTypes' 'msDS-User-Account-Control-Computed' = $Item.'msDS-User-Account-Control-Computed' Name = $Item.Name ObjectCategory = $Item.ObjectCategory ObjectClass = $Item.ObjectClass ObjectGUID = $Item.ObjectGUID objectSid = $Item.objectSid.Value Office = $Item.Office OfficePhone = $Item.OfficePhone Organization = $Item.Organization OtherName = $Item.OtherName PasswordExpired = $Item.PasswordExpired PasswordLastSet = $Item.PasswordLastSet PasswordNeverExpires = $Item.PasswordNeverExpires PasswordNotRequired = $Item.PasswordNotRequired POBox = $Item.POBox PostalCode = $Item.PostalCode PrimaryGroup = $Item.PrimaryGroup primaryGroupID = $Item.primaryGroupID PrincipalsAllowedToDelegateToAccount = $Item.PrincipalsAllowedToDelegateToAccount ProfilePath = $Item.ProfilePath ProtectedFromAccidentalDeletion = $Item.ProtectedFromAccidentalDeletion pwdLastSet = $Item.pwdLastSet SamAccountName = $Item.SamAccountName sAMAccountType = $Item.sAMAccountType ScriptPath = $Item.ScriptPath sDRightsEffective = $Item.sDRightsEffective ServicePrincipalNames = $Item.ServicePrincipalNames SID = $Item.SID.Value SIDHistory = $Item.SIDHistory SmartcardLogonRequired = $Item.SmartcardLogonRequired State = $Item.State StreetAddress = $Item.StreetAddress Surname = $Item.Surname Title = $Item.Title TrustedForDelegation = $Item.TrustedForDelegation TrustedToAuthForDelegation = $Item.TrustedToAuthForDelegation UseDESKeyOnly = $Item.UseDESKeyOnly userAccountControl = $Item.userAccountControl userCertificate = $Item.userCertificate UserPrincipalName = $Item.UserPrincipalName uSNChanged = $Item.uSNChanged uSNCreated = $Item.uSNCreated whenChanged = $Item.whenChanged whenCreated = $Item.whenCreated } } ## Publish the Maps as a Global Scope Variable $global:ADMaps = $ADMaps } } |