Converting Powershell to automated scripts
We use Powershell for finding details, setting attributes, commands etc etc. For some of the commands, what I'd like to do is have a PS script that I can run and it will prompt me for the variable. An example, using Exchange, is set-mailbox -identity USER -ProhibitSendQuota 2097152 I have read I can script this using the below and it will ask me for the USER value I want to set this command on mailbox = Read-Host "Mailbox: " set-mailbox -identity $mailbox -ProhibitedSendQuota 2097152 So far, so good. But, another common situation is trying to find an object with certain attributes: For example, finding a mailbox: get-mailbox -Attribute1 #1 -Attribute2 #2 -Attribute3 #3 ...you get the idea If I don't want to enter a value for one of these, how can I "skip" this using something similar to the above script. I found that when I am prompted and if I just hit enter, then I am returned an error saying that I have to enter something. Is there anyway in Powershell to say, if user hits "enter" [or any key] then just ignore that? So for example, I could use the following PS script, and if I didn't know the Attribute1, I could just hit Enter and it wouldn't mind not being given a value for it. Hope this makes sense.
April 13th, 2011 12:44pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics