Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # $Domains would be an input variable, its just a collection of strings: 'dadsuswe.dads.navy.mil','dadsusea.dads.navy.mil'
- # The input can come from a text file, or just a flat typed array in powershell, or it can just be one or two domains at a time
- <#
- Examples:
- $Domains = Get-Content .\domains.txt
- $Domains = @('dadsuswe...','dadsusea...','dmci-isf...')
- Then we could just do
- This-Cmdlet -Domains $Domains -File users.csv
- #>
- foreach ($Domain in $Domains){
- $psdriveObj = @{
- Server = $Domain
- Name = ($Domain.ToString().split('.')[0])
- PSProvider = ActiveDirectory
- Root = ''
- Credential = $cred
- }
- $Domain_PSDrives.Add((New-PSDrive @psdriveObj))
- }
- foreach ($drive in $Domain_PSDrives){
- Set-Location ($drive.Name + ':\')
- $i = ($drive.Server).Split('.')
- $cnStr = [System.Collections.ArrayList]::New()
- for($c=0;$c -lt ($i.count);$c++){
- $cnStr.Add(("OU="+$i[$c])) | Out-Null
- }
- $OUPath = ($ouStr + $cnStr) -Join ','
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement