I have a powershell script I put together that collects AD information from three separate domains and assembles the information into a worksheet with graphs and calculations and all that fun stuff.
Works great in ISE.
But when I go to schedule it as a task, it hangs up on connecting to the AD domain controllers.
Here is the line where it seems to get stuck:
$subOUs = Get-ADOrganizationalUnit -Filter * -SearchBase $thisDN -properties cn,description -SearchScope OneLevel -Server $domainDC -Credential $credential
$domainDC is the domain controller I'm connecting to and $credential is a PS credential assembled from password files.
$uname = $domain.domain + "\Administrator"
$pFile = $credentialFolder + $domain.domain + "_password.pwd"
$password = Get-Content $pFile | ConvertTo-SecureString
$credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $uname,$password
Any idea why I'm getting suck here?