Passing values from an array into functions

Hey guys;

I know how to do this with a .csv file; but for various reasons I want to use an array of values. Just having problems getting the parsing to work like I want it to. This might be obvious to someone who spends more time looking at powershell scripts than I do why this isn’t interpreting correctly.

Something along the lines of:

$subdomain =@("subdomain.1","subdomain.2","subdomain.3") foreach ($subdomain in $subdomain) { Set-Mailbox orgname."$_" -EmailAddresses @{add= "$_",$,$} Set-Mailbox orgname."$_" -EmailAddressPolicyEnabled $false -PrimarySmtpAddress "$" } 

I’ve tried passing $_ a bunch of ways like:

"$_" or "$_ -EmailAddress "$_"``" 

Nothing seems to quite work; which is annoying because I can pass the value of $subdomain in a something like:

 Ping "$_".com 

Any thoughts? Cheers

submitted by /u/DrTuff
[link] [comments]

Leave a Reply