Update VA Powershell

Guys. 

I am trying to update a VA with the value from a CSV file. 

Attribute1 is a DirectoryString VA. I have similar code that's works fine if the attribute is a BOOLEAN but trying to set this on a DirectoryString fails. 

#Set Runtime Parameters
$CSVImport = "C:\CSVFILE.csv"

Connect-QADService -Service "ARS-SERVER-Name" -Proxy
Import-Csv $CSVImport | ForEach-Object {
Set-QADUser -IncludedProperties 'Attribute1' -Identity $_.UserName -ObjectAttributes @{"Attribute1"=" $_.Url"}
}

Parents
  • 1. You don't need the '-IncludedProperties 'Attribute1' '.  This is only needed on "Get"

    2. For the Identity, I have gotten into the habit of explicitly casting to string - not strictly necessary coming from a file, but it just saves me headaches in general.

    -Identity [string]$_.UserName

    3.  Though probably functionally the same as what you are doing I would handle your URL property like this:

    -ObjectAttributes @{"Attribute1"=$([string]$_.Url)}

    Re 2 and 3, it's a bit of a belt and suspenders / braces approach but that's how I roll.

Reply
  • 1. You don't need the '-IncludedProperties 'Attribute1' '.  This is only needed on "Get"

    2. For the Identity, I have gotten into the habit of explicitly casting to string - not strictly necessary coming from a file, but it just saves me headaches in general.

    -Identity [string]$_.UserName

    3.  Though probably functionally the same as what you are doing I would handle your URL property like this:

    -ObjectAttributes @{"Attribute1"=$([string]$_.Url)}

    Re 2 and 3, it's a bit of a belt and suspenders / braces approach but that's how I roll.

Children