From 6f503f735fbb3d41da419e86d0480a7cc821726f Mon Sep 17 00:00:00 2001 From: Przemyslaw Klys Date: Sun, 2 Aug 2020 00:43:36 +0200 Subject: [PATCH] Why was it even here? --- Private/New-ADForestDrives.ps1 | 56 ---------------------------------- 1 file changed, 56 deletions(-) delete mode 100644 Private/New-ADForestDrives.ps1 diff --git a/Private/New-ADForestDrives.ps1 b/Private/New-ADForestDrives.ps1 deleted file mode 100644 index 1603663..0000000 --- a/Private/New-ADForestDrives.ps1 +++ /dev/null @@ -1,56 +0,0 @@ -function New-ADForestDrives { - [cmdletbinding()] - param( - [string] $ForestName, - [string] $ObjectDN - ) - if (-not $Global:ADDrivesMapped) { - if ($ForestName) { - $Forest = Get-ADForest -Identity $ForestName - } else { - $Forest = Get-ADForest - } - if ($ObjectDN) { - # This doesn't work because no Domain and no $Server - $DNConverted = (ConvertFrom-Distinguishedname -DistinguishedName $ObjectDN -ToDC) -replace '=' -replace ',' - if (-not(Get-PSDrive -Name $DNConverted -ErrorAction SilentlyContinue)) { - try { - - if ($Server) { - $null = New-PSDrive -Name $DNConverted -Root '' -PsProvider ActiveDirectory -Server $Server.Hostname[0] -Scope Global -WhatIf:$false - Write-Verbose "New-ADForestDrives - Mapped drive $Domain / $($Server.Hostname[0])" - } else { - $null = New-PSDrive -Name $DNConverted -Root '' -PsProvider ActiveDirectory -Server $Domain -Scope Global -WhatIf:$false - } - } catch { - Write-Warning "New-ADForestDrives - Couldn't map new AD psdrive for $Domain / $($Server.Hostname[0])" - } - } - } else { - foreach ($Domain in $Forest.Domains) { - try { - $Server = Get-ADDomainController -Discover -DomainName $Domain - $DomainInformation = Get-ADDomain -Server $Server.Hostname[0] - } catch { - Write-Warning "New-ADForestDrives - Can't process domain $Domain - $($_.Exception.Message)" - continue - } - $ObjectDN = $DomainInformation.DistinguishedName - $DNConverted = (ConvertFrom-Distinguishedname -DistinguishedName $ObjectDN -ToDC) -replace '=' -replace ',' - if (-not(Get-PSDrive -Name $DNConverted -ErrorAction SilentlyContinue)) { - try { - if ($Server) { - $null = New-PSDrive -Name $DNConverted -Root '' -PsProvider ActiveDirectory -Server $Server.Hostname[0] -Scope Global -WhatIf:$false - Write-Verbose "New-ADForestDrives - Mapped drive $Domain / $Server" - } else { - $null = New-PSDrive -Name $DNConverted -Root '' -PsProvider ActiveDirectory -Server $Domain -Scope Global -WhatIf:$false - } - } catch { - Write-Warning "New-ADForestDrives - Couldn't map new AD psdrive for $Domain / $Server $($_.Exception.Message)" - } - } - } - } - $Global:ADDrivesMapped = $true - } -} \ No newline at end of file