I have a powershell cmdlet (move-IMAPMailboxToExchange) that requires a lot of repetition to enter. I want to call it with another batch/powershell script that just takes two args from the command line. I've tried every calling convention I can think of but I can't make it work.
I want this:
Move-IMAPMailboxToExchange -SourcePassword P@ssW0rd! -allowunsecureconnection -sourceLoginId username -sourceserver source.ser.ver -sourceidentity [email protected] targetclientaccessserver "client.access.ser.ver" -targetidentity [email protected] -verbose
To be this:
migrate-user username P@ssW0rd!
I've tried $args, but that seems to expand. I've tried $args[0] which works in the bareword password and sourcelogin, but doesn't work next to the @mail.... I've tried %1, etc, from the old DOS days but that doesn't work.
I'm a unix dork and I'm not quite grokking powershell yet.
From what I remember, single-quotes is how PowerShell designates something as 'do not parse'. so...
You might want to do something like this
As a way to firmly declare the variables within the context of the script. If you're having trouble constructing the -sourceidentity and -targetidentity variables, you may want to pre-construct them before putting them on the move-imaptoexchange command...
You should be able to define a function or script file around your cmdlet, like this: