Dump-RBAC.ps1

#Exchange #Exchange2010 #Powershell

So I have been meaning to post this for a while, so here it is.  I have a need to dump out the RBAC permissions for Exchange 2010 so I could see who had what.  So here is is.  The output is a HTML file.  You will need to create a folder called C:ps for it save it to.

Enjoy .. feedback welcome Winking smile

 

$Error.Clear()
#########################################################################################
$AppName = "Dump-RBAC.ps1"
$AppVer  = "v1.0 [4th Feburary 20111]"
#
#v1.0  05 Aug 2011 : A Script is born

#This script exports relevant RBAC information and generate a webpage
##########################################################################################

##########################################################################################
#Load the Exchange 2010 bits & bobs
#########################################################################################
$xPsCheck = Get-PSSnapin | Select Name | Where {$_.Name -Like "*Exchange*"}
If ($xPsCheck -eq $Null) {Add-PsSnapin Microsoft.Exchange.Management.PowerShell.e2010}

##########################################################################################
#Display script name and version
#########################################################################################
Write-host " " $AppName -NoNewLine -foregroundcolor Green
Write-Host ": " $AppVer -foregroundcolor Green
Write-host "`n Run on $ServerName at $Today by $xUser" -foregroundcolor Yellow
Write-Host "|——————————————————————-|`n"
Write-host "Log Folder: $DateFolder"

$RBACArray      = @()
$RBACCmd        = @()
$RoleGroupArray = @()

$tmpCols = Get-ManagementRoleAssignment
$tmpCols | group RoleAssigneeName | sort name | Select Name | ForEach{$feName = $_.Name; $feName = $feName.Replace(" ","");$xHTML += "<td>" + $fename + "</td>"}

$x=@();$x+="RoleName"; $tmpCols | group RoleAssigneeName | sort name | Select Name | ForEach{$feName = $_.Name; $feName = $feName.Replace(" ","");$x += $fename}

$tmpgmr = Get-ManagementRole | Sort Name
Write-Host "Getting Management Role Information"
ForEach($tmpRole in $tmpgmr){
  $tmpName = $tmpRole.Name
  Write-Host $tmpName
  $tmpArray = "" | Select $x
  $tmpCmd   = "" | Select RoleName, Commands

  ($tmpRole).RoleEntries | ForEach {$tmpcmd.Commands += $_.Name + " | "}

  $tmparray.RoleName = $tmpName #$_.Role
  $tmpCmd.RoleName   = $tmpName

  $gmra = $tmpCols | where {$_.Role -eq "$TmpName"}
  $gmra | sort RoleAssigneeName | ForEacH{$yy = $_.RoleAssigneeName;
    $yy = $yy.Replace(" ","")
    $tmparray.$yy = "x"
  }
  $RBACArray += $tmpArray
  $RBACCmd   += $tmpcmd
}

$tmpRoleGroups = $tmpCols | Where {$_.RoleAssigneeType -eq "RoleGroup"} | Group RoleAssigneeName | Select Name | Sort Name
$tmpRoleGroups | ForEach{
  $tmpmem = ""
  $tmpRG = "" | Select Name, Members
  $tmpRG.Name = $_.Name
  $tmpRG.Name
  $tmpGroup = Get-Group $tmpRG.Name
  $tmpGroupMembers = $tmpGroup.Members
  $tmpGroupMembers | ForEach{$tmpRG.Members += $_.Name + " | "}
  $RoleGroupArray += $tmpRG
}

$today = Get-Date
$HtmlHeader = "
<Style>
  TABLE{border-width: 1px;padding: 1px;border-style: solid;border-color: black;border-collapse: collapse;}
  TD{border-width: 1px;padding: 1px;border-style: solid;border-color: black;}
  TH{font-family:’Arial’;font-size:12px;border-width: 1px;padding: 1px;border-style: solid;border-color: black;background-color:peachpuff;layout-flow:vertical-ideographic;Text-align:left}
  TR{font-family:’Arial’;font-size:10px}
  P{font-family:’Arial’;}
</Style>
<TITLE>Exchange Server 2010 RBAC</TITLE>"
$z="<B><FONT size=’2′ face=’VERDANA’>Exchange Server 2010 RBAC Information</B></FONT><BR><FONT size=’1′ face=’VERDANA’>Last updated: $today</FONT></font><HR size=6 color=Green>"
$xhtml = $RBACArray | ConvertTo-Html -head $HtmlHeader  -Title "Exchange Server 2010 RBAC" -body $z -PreContent "<FONT size=’2′ face=’VERDANA’>"

$txtYELLOW = @()
$i=0; $xHTML | foreach{IF ($_ -like "*<td>x</td>*"){ $txtYELLOW += $i}; $i++}
$txtYELLOW | ForEach{$xHTML[$_] = $xHTML[$_].Replace("<td>x</td>","<td bgcolor=Yellow align=center><B>x</B></td>")}

$xHTML += "<HR>"
$xHTML += $RBACCmd | ConvertTo-Html -Fragment

$xHTML += "<HR>"
$xHTML += $RoleGroupArray  | ConvertTo-Html -Fragment

$xhtml | out-file c:psrbac.html

Exchange 2010 Personal Archive & Enterprise Vault 10

#exchange2010

Interesting:

Q) Can Enterprise Vault 10 archive email that is stored an Exchange 2010 Personal Archive?

A) There is currently no capability of archiving content from the Exchange 2010 Personal Archive to Enterprise Vault. The user can either restore the content to their mailbox or if using Virtual Vault and the users ability to add content to the archive via Virtual Vault is enabled then they can drag from the personal archive directly to Virtual Vault. The caveat being that Virtual Vault is not really optimised for upload so should only really be used for small numbers of items.

Virtualized Exchange Storage: VMDK or RDM or…?

#Exchange #Exchange2010 #vmware

Matt sent me this .. an Interesting read

http://blogs.vmware.com/apps/2011/11/virtualized-exchange-storage-vmdk-or-rdm-or.html

One of the hottest topics I get into when talking to customers about virtualizing Exchange is storage. Not surprising considering the number of options available when we virtualize Exchange on vSphere. If you are not familiar with the common methods for provisioning storage in vSphere a brief description of each follows:

  • VMFS based virtual disk (VMDK) – VMFS is a high performance, clustered file system that allows concurrent access by multiple hosts to files on a shared volume. VMFS offers high I/O capabilities for virtual machines and is optimized for large VMDK files. VMFS volumes can be Fibre Channel or iSCSI attached.
  • Raw-device mappings (RDM) – RDM is a mapping file in a VMFS volume that acts as a proxy for a raw physical device, sometimes called a pass-thru disk. The RDM file contains metadata used to manage and redirect disk access to the physical device. RDMs can be Fibre Channel or iSCSI attached.

In early versions of ESX the virtualization overhead associated with deploying virtual disks (VMDK files) was much higher than it is today and why it was considered a best practice to place Exchange data files on physical mode raw-device mappings (RDM). As ESX and vSphere have evolved the performance difference between RDMs and virtual disks has become almost nonexistent. This leaves some questioning why we might choose to deploy RDMs for Exchange storage.

… “

Virtualized Exchange Storage: VMDK or RDM or…?

#Exchange #Exchange2010 #vmware

Matt sent me this .. an Interesting read

http://blogs.vmware.com/apps/2011/11/virtualized-exchange-storage-vmdk-or-rdm-or.html

One of the hottest topics I get into when talking to customers about virtualizing Exchange is storage. Not surprising considering the number of options available when we virtualize Exchange on vSphere. If you are not familiar with the common methods for provisioning storage in vSphere a brief description of each follows:

  • VMFS based virtual disk (VMDK) – VMFS is a high performance, clustered file system that allows concurrent access by multiple hosts to files on a shared volume. VMFS offers high I/O capabilities for virtual machines and is optimized for large VMDK files. VMFS volumes can be Fibre Channel or iSCSI attached.
  • Raw-device mappings (RDM) – RDM is a mapping file in a VMFS volume that acts as a proxy for a raw physical device, sometimes called a pass-thru disk. The RDM file contains metadata used to manage and redirect disk access to the physical device. RDMs can be Fibre Channel or iSCSI attached.

In early versions of ESX the virtualization overhead associated with deploying virtual disks (VMDK files) was much higher than it is today and why it was considered a best practice to place Exchange data files on physical mode raw-device mappings (RDM). As ESX and vSphere have evolved the performance difference between RDMs and virtual disks has become almost nonexistent. This leaves some questioning why we might choose to deploy RDMs for Exchange storage.

… “

New-MoveRequest Fails at 95%

#Exchange2010 #Exchange

I had a single mailbox, that I could not move from Exchange 2003 to Exchange 2010.  It moved from 2003 to another 2003 database no problem, but 2003 to 2010 no chance.

From the MoveRequest Log you could see this at the end:

12/10/2011 1:04:36 AM [CAS] Fatal error UpdateMovedMailboxPermanentException has occurred.
Error details: An error occurred while updating a user object after the move operation. –> Active Directory operation failed on MyDC. One or more attribute entries of the object ‘BadUser’ already exists. –> The attribute exists or the value has been assigned.
   at Microsoft.Exchange.MailboxReplicationService.LocalMailbox.Microsoft.Exchange.MailboxReplicationService.IMailbox.UpdateMovedMailbox(UpdateMovedMailboxOperation op, ADUser remoteRecipientData, String domainController, ReportEntry[]& entries, Guid newDatabaseGuid, Guid newArchiveDatabaseGuid, String archiveDomain, ArchiveStatusFlags archiveStatus)
   at Microsoft.Exchange.MailboxReplicationService.MailboxWrapper.<>c__DisplayClass3c.<Microsoft.Exchange.MailboxReplicationService.IMailbox.UpdateMovedMailbox>b__3b()
   at Microsoft.Exchange.MailboxReplicationService.ExecutionContext.Execute(GenericCallDelegate operation)
   at Microsoft.Exchange.MailboxReplicationService.MailboxWrapper.Microsoft.Exchange.MailboxReplicationService.IMailbox.UpdateMovedMailbox(UpdateMovedMailboxOperation op, ADUser remoteRecipientData, String domainController, ReportEntry[]& entries, Guid newDatabaseGuid, Guid newArchiveDatabaseGuid, String archiveDomain, ArchiveStatusFlags archiveStatus)
   at Microsoft.Exchange.MailboxReplicationService.LocalMoveJob.UpdateMovedMailbox()
   at Microsoft.Exchange.MailboxReplicationService.MoveBaseJob.UpdateAD(Object[] wiParams)
   at Microsoft.Exchange.MailboxReplicationService.CommonUtils.CatchKnownExceptions(GenericCallDelegate del, FailureDelegate failureDelegate)
Error context: ——–
Operation: IMailbox.UpdateMovedMailbox
OperationSide: Target
Primary (62d90226-d9a1-4941-baa5-28104b5fab78)
12/10/2011 1:04:36 AM [CAS] Relinquishing job.

It turns out that in when looking in the AD at the user proxy addresses a couple of them had an Š instead of an S.

When you looked with Exchange, it showed the S and not Š

So it’s an extended ASCII character (_http://en.wikipedia.org/wiki/%C5%A0 (_http://en.wikipedia.org/wiki/%C5%A0)). 

When I have changed it to a “normal” S using ADSIEdit, the move then worked!

How funky! .. Interesting in the Get-Mailbox still tagged the mailbox as valid!

Virus of the week (2012-01-09)

#Exchange #Exchange2010 #Virus

So this is a summary of what Microsoft Forefront Protection for Exchange Server detected as a virus.

Trojan-Spy.HTML.Fraud.gen

  • Subject line:  "Botanical Gardens Boot Camp NOW STARTING"
  • Subject line:  "Just for Cardholders: Save an extra 10% on select TVs at Amazon.com"
  • Subject line:  "Bank of America Customer Service – Tell us what you think"
  • Subject line:  "PayPal – Your account has been limited!"

Win32/Pdfjsc.RF

MSWord/Dropper.B!Camelot   

  • File name:  "winmail.dat->Insurance.zip->1036775_4909136e-c76f-466a-a8fe-a935fb735dbd_TATAAIGFIRSTPLAN.doc"

    Prognosis Webinar – Top 5 ways to Microsoft Lync success

    #Lync

    Could be interesting

    If you haven’t already registered to attend next week’s Prognosis for Microsoft Lync Webinar, please REGISTER NOW by clicking on the date below for your region. 
    In this 60-minute webinar you can learn how Prognosis bridges the gap between server infrastructure management and UC management teams and build the new management skills you need to integrate Microsoft Lync server and voice quality performance management. Accelerate the transition from server and application expertise to real-time Unified Communications management!

    Webinar:

    Top 5 ways to ensure success in your Microsoft Lync deployment

    Dates:

    Australia: Tuesday, 17 January 2012, 1pm – 2pm AEDT
    Americas: Wednesday, 18 January 2012, 2:00pm – 3:00pm EST
    Europe: Wednesday, 18 January 2012, 1:00pm – 2:00pm GMT

    Get-RegistryValue

    #Powershell

    So I have been messing with Powershell for a while now, Jeff asked me to look at script he had that read remote registry values.  He was using PSRemoteRegistry but got some errors.

    So I knocked this function up for him Winking smile

    function Get-RegistryValue([Switch]$Recurse=$false, [String]$ComputerName=(hostname), [String]$Hive="HKLM", [String]$key)
    {
      $OutArray = @()
      Switch($Hive){
        "HKCR"  {$type = [Microsoft.Win32.RegistryHive]::ClassesRoot}
        "HKU"   {$type = [Microsoft.Win32.RegistryHive]::Users}
        "HKPD"  {$type = [Microsoft.Win32.RegistryHive]::PerformanceData}
        "HKDD"  {$type = [Microsoft.Win32.RegistryHive]::DynData}
        "HKCU"  {$type = [Microsoft.Win32.RegistryHive]::CurrentUser}
        "HKLM"  {$type = [Microsoft.Win32.RegistryHive]::LocalMachine}
      }#Case

      $regKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($type, $ComputerName)
      $regKey = $regKey.OpenSubKey($key)
      If($regKey -eq $Null){Write-Host "Registry Key ["$Hive""$key"] Not Found" -ForeGroundColor Red;Return}
      Write-Host "`n"$regkey -ForeGroundColor Blue
      If ($Recurse -AND $regKey.SubKeyCount -gt 0){

        ForEach($sub in $regKey.GetSubKeyNames()){
          $SUBkey = $key + "" + $Sub
          Get-RegistryValue -ComputerName $ComputerName -Hive $Hive -Key $SUBKey -Recurse $Recurse
        }#ForEach
      }#If
      ForEach($Subx in $RegKey.GetValueNames()){
        $RegArray = "" | Select ComputerName, Key, Value, path
        $RegArray.ComputerName = $ComputerName
        $RegArray.Key          = $SubX
        $RegArray.Value        = $Regkey.GetValue($SubX)
        $RegArray.Path         = $RegKey.Name
        $OutArray             += $RegArray
      }#ForEach
    Return $OutArray
    }#End Function Get-RegistryValue

    Essentially all you need to do is

    Get-RegistryValue –ComputerName <Computername> -Key "SYSTEMCurrentControlSetservicesSNMPParametersTrapConfiguration" -Hive HKLM –Recurse

    You change the -Hive switch to the particular registry hive (by default it will use HKLM), give it a computername (by default it will use the localhost) and a registry key path .. Done!

    You can also recurse a registry if there are subkeys .. nice Open-mouthed smile

    Let me know what you think