Value Expression Operator '-'
I am new to PowerShell. I started learning it a few days ago.
I know my question my be dumb, I was wondering if any of you can help me.
I was using Exchange Management Shell and I trying to change a PramaterType called UseDatabaseQutaDefaults as $True for a user.
I had assigned the user's mailbox to a variable $s. The reason was b/c I want to be able to assigned multiple names or use the Get-Content in the future if I have a bulk of users.
$s = Set-Mailbox Test.User
Commands that I tried changing the UseDatabaseQuotaDefaults
$s UseDatabaseQuotaDefaults $True
$s -UseDatabaseQuotaDefaults $True
I'm getting the following error
Missing expression after unary operator '-'.
At line:1 char:7
+ $s | – <<<< UseDatabaseQuotaDefaults $true
+ CategoryInfo : ParserError: (-:String) , ParentContainsErrorRecordException
+ FullyQualifiedErrorId : MissingExpressionAfterOperator
I was wondering if someone can explain to me why this doesn"t work. I"m exploring PowerShell right now to see what other ways I can do it.
I know it works if i do "Set-Mailbox Test.User -UseDatabaseQuotaDefaults $True
$s contains whatever is output from Set-Mailbox. I'm not sure that Set-Mailbox actually outputs anything, so $s may be null.
Set-Mailbox -Identity TestUser -UseDatabaseQuotaDefaults $true
Would run the command, changing the user's quota to use the database quota defaults. This change is done by running the command, and providing parameters to the command.
Thank You Don.
That make sense that $s maybe null. I'll explorer around a little bit more on how it works.
Since, I started learning PowerShell. I always thought that when assigning a Variable to whatever contents are stored in that Variable. I could always call the Variable to do certain Commands/Changes.
I guess I should read more about assigning a variable to Get-Content or using Script Block.
You must be logged in to reply to this topic.