Updated 2/21/2013 - Why didn't anyone tell me this was ugly? Fixed so that the tables render correctly
***THIS ONLY WILL WORK IN POWERSHELL V3 (Win8 and Server 2012)***
The script will run in Powershell V2, but the data in the output tables will contain only the type information and not the actual data.
To use this script, you must be connected to Exchange remote powershell. Replace the URI below with the URI for your CAS. Replace "basic" with whatever authentication means you allow on the "powershell" IIS vdir on CAS. This may be "kerberos"
if you are on a domain joined machine.
PowerShell
Edit|Remove
powershell
$cred = get-credentials
$session = new-pssession -configurationname Microsoft.Exchange -connectionuri "https://mail.contoso.com/powershell" -authentication basic -credentials $cred
import-pssession $session
$cred = get-credentials
$session = new-pssession -configurationname Microsoft.Exchange -connectionuri "https://mail.contoso.com/powershell"-authentication basic -credentials $cred
import-pssession $session
This script with iterate through all roles defined and then through each entry.
It will output all of the allowed Commandlets for each role and what parameters are available.
Example Output:
Role:Recipient Policies
| Name |
Parameters |
| Write-AdminAuditLog |
Comment Confirm Debug DomainController ErrorAction ErrorVariable OutBuffer OutVariable Verbose WarningAction WarningVariable WhatIf |
| Set-ThrottlingPolicyAssociation |
Confirm Debug DomainController ErrorAction ErrorVariable Identity OutBuffer OutVariable ThrottlingPolicy Verbose WarningAction WarningVariable WhatIf |
PowerShell
Edit|Remove
powershell
param([string]$outfile=".\roles.htm")
$roles = Get-ManagementRole
$arRoles = @()
foreach ($role in $roles)
{
$RoleData = New-Object Object
$RoleData | Add-Member -type NoteProperty -name RoleName -value $role.Name
$rolepath = $role.name + "\*"
$RoleData | Add-Member -type NoteProperty -name Entry -value (Get-ManagementRoleEntry $rolepath)
$arRoles += $RoleData
}
$head = "<h1>Roles Export<br></h1>"
$head | out-file $outfile
$a = ""
$a | out-file $outfile -Append
foreach ($role in $arroles)
{
$body = "<h2>Role: " +$role.RoleName + "<br></h2>"
$body | out-file $outfile -Append
$role.entry | Select-Object name,parameters | ConvertTo-Html -Fragment| Out-File $outfile -Append
}
param([string]$outfile=".\roles.htm")
$roles = Get-ManagementRole
$arRoles = @()
foreach ($role in $roles)
{
$RoleData = New-Object Object
$RoleData | Add-Member -type NoteProperty -name RoleName -value $role.Name
$rolepath = $role.name + "\*"
$RoleData | Add-Member -type NoteProperty -name Entry -value (Get-ManagementRoleEntry $rolepath)
$arRoles += $RoleData
}
$head = "<h1>Roles Export<br></h1>"
$head | out-file $outfile
$a = ""
$a | out-file $outfile -Append
foreach ($role in $arroles)
{
$body = "<h2>Role: " +$role.RoleName + "<br></h2>"
$body | out-file $outfile -Append
$role.entry | Select-Object name,parameters | ConvertTo-Html -Fragment| Out-File $outfile -Append
}