Guys.
I have this Powershell script that i am running as part of a ARS scheduled task. When the schedule task runs i see the below error. However if i run the script outside of ARS then it runs fine.
Any ideas?
PS>TerminatingError(Set-QADUser): "Cannot validate argument on parameter 'Identity'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again."
>> TerminatingError(ForEach-Object): "Cannot validate argument on parameter 'Identity'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again."
>> TerminatingError(ForEach-Object): "Cannot validate argument on parameter 'Identity'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again."
>> TerminatingError(ForEach-Object): "Cannot validate argument on parameter 'Identity'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again."
Cannot validate argument on parameter 'Identity'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
>> set-psdebug -trace 0
PS>s5367706b-f0e4-4789-92ac-c4b8f57e2faa 'onPostGet' $Request
PS>set-psdebug -trace 0
PS>s5367706b-f0e4-4789-92ac-c4b8f57e2faa 'onPreSearch' $Request
PS>set-psdebug -trace 0
PS>s5367706b-f0e4-4789-92ac-c4b8f57e2faa 'onPostGet' $Request
$AzureLocation = $Task.DirObj.Parameters.Value("AzureLocation").Value $date = Get-Date $date = $date.ToString("dd-MMM-yyyy") $time = Get-Date -Format "dd-MMM-yyyy-HH-mm" $CSVLocation = "C:\Temp\OneDrive-Import-Export" $logfile = "$CSVLocation\Logs\$AzureLocation-OneDrive-$time.txt" Start-Transcript -Path $logfile -Append #CSV Import Location $CSVImport = "$CSVLocation\$Date\$AzureLocation-OneDrive.csv" #Connect-QADService -Service "Admin-Service-FQDN" -Proxy Import-Csv $CSVImport | ForEach-Object { $CurrentUser = [string]$_.UserName $OneDriveSiteUrlContents = [string]$_.OneDriveSiteUrl $TargetUser = Get-QADUser -LdapFilter "(userprincipalname=$CurrentUser)" | select -expandproperty DN Set-QADUser -Identity $TargetUser -ObjectAttributes @{"OneDrive-URL"=$OneDriveSiteUrlContents} }