Question : powershell

hi,
im new to PS

Im trying to run .ps1 script but im getting "no user specified"

im not sure how to input user name.

Can you please help.

Thanks


script attached  
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
# Get-MailboxQuota.ps1

# Script for showing mailbox size and quota

 

# Exit the script if username is not found

If ($args[0] -eq $null) {

      Write-Host "Error: No user specified" -ForegroundColor "Red"

      break

}

 

# Get the username from the command line argument

$username = $args[0]

 

# Get the mailbox, break if it's not found

$mb = Get-Mailbox $username -ErrorAction Stop

 

# Get the mailbox statistics

$mbstats = Get-MailboxStatistics $username

 

# If the mailbox is using the database quotas then read them, otherwise read them from the mailbox

If ($mb.UseDatabaseQuotaDefaults -eq $true) {

      $quota = (Get-MailboxDatabase -Identity $mb.Database).ProhibitSendQuota.Value.ToMB()

} else {

      $quota = $mb.ProhibitSendQuota.Value.ToMB()

}

 

# Get the mailbox size and convert it from bytes to megabytes

$size = $mbstats.TotalItemSize.Value.ToMB()

 

# Write the output

Write-Host "Mailbox:   " $mb.DisplayName

Write-Host "Size (MB): " $size

Write-Host "Quota (MB):" $quota

Write-Host "Percent:   " ($size/$quota*100)

Write-Host

Answer : powershell


for better result that is suitable for excel, use the following command instead

Get-Mailbox | Get-MailboxStatistics | Format-Table DisplayName,StorageLimitStatus,TotalItemSize
Random Solutions  
 
programming4us programming4us