Value Expression Operator '-'

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of KnowledgeChi KnowledgeChi 1 year, 6 months ago.

  • Author
  • #24105
    Profile photo of KnowledgeChi

    Hello All,

    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

  • #24106
    Profile photo of Don Jones
    Don Jones

    $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.

  • #24107
    Profile photo of KnowledgeChi

    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.