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
 
  •