This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$params = @{ | |
SearchBase = (Get-ADDomain).DistinguishedName | |
Filter = { proxyAddresses -like '*' } | |
Properties = 'Displayname', | |
'SamAccountName', | |
'UserPrincipalName', | |
'ProxyAddresses', | |
'DistinguishedName' | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 -EA SilentlyContinue | |
Set-AdServerSettings -ViewEntireForest $true | |
$OutFile = ".\Exchange_Permission_Export.csv" | |
"DisplayName" + "!" + "Alias" + "!" + "OU" + "!" + "PrimarySMTP" + "!" + "FullAccess" + "!" + "SendAs" + "!" + "SendonBehalf" | Out-File $OutFile -Force -encoding ascii | |
# $Mailboxes = import-csv .\perms.csv | |
$Mailboxes = Get-Mailbox -ResultSize:Unlimited | Select DistinguishedName, UserPrincipalName, DisplayName, Alias, | |
@{n = "OU" ; e = {$_.Distinguishedname | ForEach-Object {($_ -split '(OU=)', 2)[1, 2] -join ''}}} | |
ForEach ($Mailbox in $Mailboxes) { | |
Write-Output "Mailbox: $($Mailbox.UserPrincipalName)" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 -EA SilentlyContinue | |
Set-AdServerSettings -ViewEntireForest $true | |
$OutFile = ".\Exchange_Permission_Export.csv" | |
"DisplayName" + "!" + "Alias" + "!" + "OU" + "!" + "PrimarySMTP" + "!" + "FullAccess" + "!" + "SendAs" + "!" + "SendonBehalf" | Out-File $OutFile -Force -encoding ascii | |
# $Mailboxes = import-csv .\perms.csv | |
$Mailboxes = Get-Mailbox -ResultSize:Unlimited | Select DistinguishedName, UserPrincipalName, DisplayName, Alias, | |
@{n = "OU" ; e = {$_.Distinguishedname | ForEach-Object {($_ -split '(OU=)', 2)[1, 2] -join ''}}} | |
ForEach ($Mailbox in $Mailboxes) { | |
Write-Output "Mailbox: $($Mailbox.UserPrincipalName)" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-Mailbox : Cannot bind parameter 'Identity'. Cannot convert value "" to type | |
"Microsoft.Exchange.Configuration.Tasks.MailboxIdParameter". Error: "Parameter values of type | |
Microsoft.Exchange.Configuration.Tasks.MailboxIdParameter can't be empty. Specify a value, and try again. | |
Parameter name: identity" | |
At C:\scripts\Get_Mailbox_Permissions.Exchange2.ps1:15 char:69 | |
+ ... Fullaccess = (($FullAccess).split("!!") | % {((get-mailbox $_).Displa ... | |
+ ~~ | |
+ CategoryInfo : InvalidArgument: (:) [Get-Mailbox], ParameterBindingException | |
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.Exchange.Management.RecipientTasks.GetMailbox |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ConvertTo-DistinguishedName { | |
[CmdletBinding()] | |
[OutputType([string])] | |
Param | |
( | |
# e.g. 'corp.ad.contoso.com/CORP/USERS/Person' | |
[Parameter(Mandatory = $true, | |
Position = 0)] | |
[ValidateNotNullOrEmpty()] | |
# must be at least a.b/w - no single character domain or missing path |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-ADUser -Filter 'proxyaddresses -ne "$null"' -ResultSetSize $null -Properties DisplayName, samaccountname, UserPrincipalName, proxyAddresses, Distinguishedname -searchBase "DC=CONTOSO,DC=local" | | |
select DisplayName, samaccountname, UserPrincipalName, | |
@{n = "OU" ; e = {$_.Distinguishedname | ForEach-Object {($_ -split '(OU=)',2)[1,2] -join ''}}}, | |
@{n = "PrimarySMTP" ; e = {( $_.proxyAddresses | ? {$_ -cmatch "SMTP:*"}).Substring(5) -join ";" }}, | |
@{n = "smtp" ; e = {( $_.proxyAddresses | ? {$_ -cmatch "smtp:*"}).Substring(5) -join ";" }}, | |
@{n = "x500" ; e = {( $_.proxyAddresses | ? {$_ -match "x500:*"}).Substring(0) -join ";" }}, | |
@{n = "SIP" ; e = {( $_.proxyAddresses | ? {$_ -match "SIP:*"}).Substring(4) -join ";" }} | | |
Export-Csv ADUsers.csv -NTI |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Param ( | |
[Parameter(Mandatory = $True)] | |
$givenname, | |
[Parameter(Mandatory = $True)] | |
$surname, | |
[Parameter(Mandatory = $True)] | |
$template, | |
[Parameter(Mandatory = $False)] | |
$password = "contoso2830!!", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Param ( | |
[Parameter(Mandatory = $True)] | |
$givenname, | |
[Parameter(Mandatory = $True)] | |
$surname, | |
[Parameter(Mandatory = $False)] | |
$storeNum, | |
[Parameter(Mandatory = $False)] | |
$mobile, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Sync-ADConnect { | |
Param ( | |
[Parameter(Mandatory = $False)] | |
[switch] $Initial, | |
[Parameter(Mandatory = $False)] | |
$aadComputer = "se-c-ac01.corp.ad.sentara1.com" | |
) | |
<# | |
.SYNOPSIS | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$i = 1 | |
while (get-aduser -LDAPfilter "(userprincipalname=$userprincipalname)") { | |
$FirstName = $FirstName + $i | |
$userprincipalname = $LastName.replace(" ", "") + "-" + $FirstName.replace(" ", "") + "@" + $PsBoundParameters[$ParamName_emaildomain] | |
$i++ | |
} | |
$name = $LastName + ", " + $FirstName |