KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm trying to use a variable as a command's parameter but can't quite figure it out. Let's say MyCommand will accept two parameters: option1 and option2 and they accept boolean values. How would I use $newVar to substitute option 1 or 2? For example: $newVar = "option1" MyCommand -$newVar:$true I keep getting something along the lines of 'A positional parameter cannot be found that accepts argument '-System.String option1' . More Specifically: Here, the CSV file is an output of a different policy. The loop goes through each property in the file and sets that value in my policy asdf ; so -$_.name:$_.value should substitute as -AllowBluetooth:true . Import-Csv $file | foreach-object { $_.psobject.properties | where-object { # for testing I'm limiting this to 'AllowBluetooth' option if($_.name -eq "AllowBluetooth"){ Set-ActiveSyncMailboxPolicy -Identity "asdf" -$_.name:$_.value }} }
Tags (comma-separated)
Save Edits
Cancel