Monthly Archives: September 2014

PowerShell and Roku API

Below is a simple one liner to send a command to your Roku via PowerShell command.

Invoke-WebRequest -uri '' -Method POST -Body ""

Pull AD Group Members and Member Properties

##Pull Active Directory Group Members, and Member Properties
##Get AD Groups via text file or Get-ADGroup command
$adGroups = Get-Content “C:\Temp\adGroups.txt”;
#$adGroups = Get-ADGroup -Filter *;

Foreach ( $group in $adGroups ) {
     $groupName = $group;
     #$groupName = $group.Name;
     $adGroupMembers = Get-ADGroupMember $groupName;

     Foreach ( $member in $adGroupMembers ) {
          $memberSamAcct = $member.SamAccountName;
          $adUser = Get-ADUser $memberName;
          ##Get other AD User attributes here
          echo “$groupName,$memberSamAcct”;

PowerShell Compare User Info in Multiple Domains

Below is a script to compare a user’s Given Name between two domains.  Useful for a development and production comparison.

##Get Domain Credentials
$domain1Creds = Get-Credential ##Enter credentials for first domain;
$domain2Creds = Get-Credential ##Enter credentials for first domain;

##Get Domain Users
$adUsersD1 = Get-ADUser -Filter * -Server Domain1 -Credential $domain1Creds;
$adUsersD2 = Get-ADUser -Filter * -Server Domain2 -Credential $domain2Creds;

Foreach ( $user in $adUsersD1 ) {
     $userName = $user.SamAccountName;
     $userGivenName = $user.GivenName;

     ##Get Index and entry of user in the adUsersD2 array
     $d2Index = $adUsersD2.SamAccountname.IndexOf($userName);
     $user2Compare = $adUsersD2[$d2Index];

     ##Compare Given name from domain1 to domain2
     if ( $userGivenName -ne $user2Compare.GivenName ) {
          echo “$userName Given name is different in domain2”;