Posts Tagged ‘Powershell’

Export Contact information from Office 365 (or Exchange 2010 +)

September 13th, 2013

The following exports all contacts and selected information.  This is an Exchange/Office 365 commandlet so you will need to be connected appropriately:

get-contact -resultsize unlimited | Select-Object name,FirstName,LastName,displayname,Company,WindowsEmailAddress | Export-Csv c:\script\user_audit.csv -Delimiter "|"

Tags: ,
Posted in Uncategorized | Comments (0)

Export AD Password and Account Information using Get-QADUser

August 20th, 2013

You will need the free Quest Active Roles Management Shell to perform this function:

Get-QADUser -Name * -SizeLimit 0 | select givenName,sn,name,samaccountname,company,description,PasswordExpires,PasswordNeverExpires,PasswordLastSet,lastLogonTimestamp,AccountIsDisabled,AccountExpires | Export-Csv c:\script\user_audit.csv -Delimiter "|"

To see a good list of fields to query:

Posted in Uncategorized | Comments (0)

RDS Powershell new-rdremoteapp syntax to publish app on Server 2012

June 13th, 2013

Powershell Command to fully publish app. The -VirtualFilePath is not well documented and if not set will result in not being able to configure the app through the GUI.

new-rdremoteapp -Alias "{appname no spaces}" -DisplayName "{friendly display name}" -FilePath "{full file path example: D:\Program Files (x86)\JDEdwards\B7\system\Bin32\oexplore.exe}" -VirtualFilePath "{full file path example: D:\Program Files (x86)\JDEdwards\B7\system\Bin32\oexplore.exe}" -ShowInWebAccess 1 -collectionname {your collection name} -ConnectionBroker {}

Tags: ,
Posted in Uncategorized | Comments (0)

Powershell Export Specific Fields to CSV

June 13th, 2013

If you only want specific fields/columns from a command to show in the export file use the following syntax. In my example I was getting all of the members of an AD group and only wanted certain logon name information.

Get-QADGroupMember CTX-ProductVision-Prod | select-object LogonName,UserPrincipalName,NTAccountName,SAMAccountName,DN | Export-Csv c:\scripts\pv.csv -Delimiter "|"

Posted in Uncategorized | Comments (0)

Scripting Office 365 license assignment

April 1st, 2013

I had a need to script the removal of one license type and add another type from a list of users. Below is how I accomplished this. You will need to create a csv file with a single column with a header of “UserPrincipalName”.


That will output your sku’s. Once you have that you would run a script like this:

Connect-MSOLService -Credential $cred
$AccountSkuIdAdd = "myco:STANDARDPACK"
$AccountSkuIdRemove = "myco:ENTERPRISEPACK"
$UsageLocation = "US"
$LicenseOptions = New-MsolLicenseOptions -AccountSkuId $AccountSkuIdAdd
$Users = Import-Csv c:\scripts\users.csv
$Users | ForEach-Object
Set-MsolUser -UserPrincipalName $_.UserPrincipalName -UsageLocation $UsageLocation
Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -RemoveLicenses $AccountSkuIdRemove
Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -AddLicenses $AccountSkuIdAdd

Additional Options:
if you wanted to do this for everyone you would change the line:
$users | Import-Csv c:\Users.csv
$users | get-msoluser -resultsize unlimited
For Granular License options:


Tags: ,
Posted in Uncategorized | Comments (0)