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:

http://powershellreflections.wordpress.com/2011/02/07/finding-stale-user-accounts-with-quest-cmdlets/

Tags:
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 {servername.domainname.com}

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 "|"

Tags:
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”.

Connect-MsolService
Get-MsolAccountSku

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
to:
$users | get-msoluser -resultsize unlimited
For Granular License options:
http://digitalglue.wordpress.com/2012/11/29/office-365-granular-license-assignment-via-powershell/

References
http://technet.microsoft.com/en-us/library/dn194094.aspx
http://technet.microsoft.com/library/jj151815.aspx
http://community.office365.com/en-us/forums/148/t/64644.aspx
http://community.office365.com/en-us/forums/148/t/17328.aspx

Tags: ,
Posted in Uncategorized | Comments (0)