Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Passing and accessing Arguments

$
0
0
Normal 0 false false false EN-GB X-NONE X-NONE MicrosoftInternetExplorer4

Hi

I have run this command successfully.

$userlist = get-content "c:\userlist.txt"

$MailboxInfo = ForEach ($user in $userlist) { get-mailbox $user | Select-object Displayname, Database, SamAccountName, ServerName, Alias, PrimarySmtpAddress, RecipientType, DistinguishedName, name}

 

Then i wanted to access individual items within $mailboxinfo, so i could format it, so i thought i put it in a function like this sending the information to another function called report. i know running the previous command to get $mailboxinfo does have the correct data as i outputed it to a text file. But below is producing no data at all. I have not passed arguments before so am i doing it incorrectly?

Any help is really appreciated

Function GetMailboxDetails($MailboxInfo)

{            Foreach($Name in $MailboxInfo) {

            $mdisplayname = $mailboxinfo.Displayname

            $mdatabase = $MailboxInfo.Database

            $mServerName = MailboxInfo.ServerName

            $mSamAccountName = MailboxInfo.SamAccountName

            $mAlias = MailboxInfo.Alias

            $mPrimarySmtpAddress = MailboxInfo.PrimarySmtpAddress

            $mRecipientType = MailboxInfo.RecipientType

            $mDistinguishedName = MailboxInfo.DistinguishedName

            $mname = MailboxInfo.name

Report $mDisplayname, $mDatabase, $mSamAccountName, $mServerName, $mAlias, $mPrimarySmtpAddress, $mRecipientType, $mDistinguishedName, $mname                                                          

}

}

 

Normal 0 false false false EN-GB X-NONE X-NONE MicrosoftInternetExplorer4

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles