Friday, December 21, 2012

Simple Powershell Scripts

qad* commands:

You'll need to download the free PowerShell Commands for Active Directory from http://www.quest.com/

Exchange commands:

You may need to install the Exchange Management tools from the Exchange ISO and then run Add-PSSnapin microsoft.exchange.management.powershell.e2010



#get home dir paths

foreach ($user in get-content usernames.txt)
 {get-qaduser -identity $user | select homedirectory
       }

#set home dir paths

foreach ($user in get-content usernames.txt)
 {set-qaduser -identity $user -homedirectory "<UNC Home Dir Path>"
       }


# Set AD company attribute and AD extension attribute #2

foreach ($user in get-content usernames.txt)
 {set-qaduser -identity $user -company "<Company Name>" -objectAttributes @{extensionAttribute2="<text>"}
       }

 #Set AD user attributes

foreach ($user in get-content usernames.txt)
 {
 get-qaduser -identity $user | select cn,creationdate,city,NTAccountName
       }


#Set UPN

foreach ($user in get-content usernames.txt)
 {set-qaduser -identity $user -userprincipalname $user@<new domain.com>
       }
      

#Get AD user attributes 

foreach ($user in get-content usernames.txt)
 {get-qaduser -identity $user -includeallproperties | select PrimarySMTPAddress,email,PrimarySMTPAddressSuffix,UserPrincipalName,sn,FirstName,LastName,logonName,displayname,StateOrProvince,city     }


#Get AD computer attributes and save to .csv file

Add-PSSnapIn -Name Quest.ActiveRoles.Admanagement
get-qadcomputer * -sizelimit 0 -includeallproperties | select Name,ComputerName,cn,description,whenCreated,whenChanged,operatingSystem,operatingSystemServicePack,dNSHostName,ComputerRole,DnsName,DN,Type,parentcontainer,managedby,extensionattribute15 | Export-Csv "D:\temp\AllADComputerObjects.csv"

remove-item  <Old File Path>
copy-item “D:\temp\AllADComputerObjects.csv” <New Path>

 #Get all email addresses for all objects

Add-PSSnapin microsoft.exchange.management.powershell.e2010
 get-mailbox * -resultsize unlimited -domaincontroller <Domain Controller> | select SamAccountName -expand EmailAddresses | Export-Csv <outpot.csv>

Thursday, December 20, 2012

Fixing DPM 2010 Reporting Services

A useful function in DPM 2020 are the reporting capabilities.  You can generate reports to view recovery point status, disk/tape usage, etc.....
 
If the reporting function doesn't work, it may be related to the account that is used in the Reporting Services configuration.  For example, if the password you set for the reporting services account doesn't meet the local password policy, reporting functionality will fail.
 
To fix this:

  • Set valid password for Reporting Services account 
  • Name:  DPMR$<ServerName>
  •  Password:  *******
  • Verify account is in group:  DPMDBReaders$<ServerName>
  • Go to the Reporting Services Web page: 
  •  Click on DPMReports – DPMReporterDataSource
  • In the “Connect Using” section:
  • Select “Credentials stored securely in the report server”
  • Enter above username and password
  • Select “Use as Windows credentials when connecting…..
  • Click on Apply
  • Stop and start Reporting Services Instance
  • Confirm the reports are functioning
 
  • 

Wednesday, November 28, 2012

Round Robin


Has your storage administrator ever contacted you saying only one path is being used by your ESXi environment?  He may have noticed this by looking at the SAN's performance and the total throughput of each path.

 






In this case, all activity is through one of the paths while the other paths are basically idle.

Setting a single LUN in vSphere is easy
  1. Select the host - Configuration tab - storage
  2. Right click on a datastore - select properties - Manage Paths
  3. On Path Selection, ensure it is set to Round Robin








When building an ESXi host, you can run this command via SSH so that Round Robin is set by default:

  • esxcli nmp satp setdefaultpsp --satp VMW_SATP_ALUA --psp VMW_PSP_RR
Note:  Make sure you have two dashes for each

If you have multiple ESXi hosts with multiple LUNS, setting each path manually can be time consuming.  In this case, you can use powershell.  This command will look at all LUNS and set the path policy to roundrobin if it's not already set:
  • Get-ScsiLun -VmHost <ESXi Host Name> -LunType disk | Where { $_.MultipathPolicy -notlike “roundrobin“}  | Set-ScsiLun -MultipathPolicy “roundrobin"
You can then run this command against all your hosts.

Once everything is set to Round Robin, you and your storage administrator will be much happier as throughput will be spread across all paths.