Friday, 23 September 2016

How to easily view/find the distinguished name for an Active Directory user account

The distinguished name for a user account is often required for scripting or other management/administrative tasks when working with Active Directory. It represents the unique identifier for every user account so is one of the best ways to work with user accounts (as opposed to just working off first name, last name etc).

They are difficult to remember, and nearly impossible to type using the correct format/syntax - so here's some simple instructions on how to quickly/easily obtain the distinguished name for a user account from Active Directory Users & Computers;

  1. Open Active Directory Users & Computers
  2. Ensure "Advanced Features" are enabled (go to View > Advanced Features)
  3. Open the Active Directroy User object you wish to view the DN for
  4. Select the Attribute Editor tab
  5. Scroll down to the locate the Distinguished Name value
  6. You can double click the entry then copy it to the clipboard from the "Value" field as per the screenshot below

Thursday, 22 September 2016

Copy Active Directory User Group Memberships to Another User with Powershell

I have developed the below script to allow you to easily copy Active Directory user group memberships from one user to another. This can be handy if a user is a member of a large number of groups and you don't wish to manually copy them over.

This script is also beneficial in that it doesn't require the Active Directory modules to be installed in powershell for it to work.

In order for the script to work, you will first need to know the distinguished name (DN) for both the source and target user accounts. This can be easily obtained from Active Directory Users & Computers using the steps below;


  1. Open Active Directory Users & Computers
  2. Ensure "Advanced Features" are enabled (go to View > Advanced Features)
  3. Open the Active Directroy User object you wish to view the DN for
  4. Select the Attribute Editor tab
  5. Scroll down to the locate the Distinguished Name value
  6. You can double click the entry then copy it to the clipboard from the "Value" field as per the screenshot below

Once you have the source and target user distinguished names, replace the values for the $srcuserdn and $dstuserdn variables. Be sure to leave the quotes ("") in place

$srcuserdn = "CN=Mike,CN=Users,DC=morrissey,DC=local"
$dstuserdn = "CN=Peter,CN=Users,DC=morrissey,DC=local"
$dstuserldap = "LDAP://$dstuserdn"

$grouplist = dsquery user $srcuserdn | dsget user -memberof

foreach ($group in $grouplist)
    {
    if ($group)
        {
        $group = $group.substring(1,$group.length-2)
        $ldapcon = "LDAP://$group"
        $ldapgroup = [ADSI] $ldapcon
        $ldapgroup.add($dstuserldap)
        }
    }

Wednesday, 21 September 2016

uTorrent - A newer version of uTorrent is already running

I've experienced this problem a few times with uTorrent - when attempting to open the application, or opening a new torrent file, the following error message is displayed;



"A newer version of uTorrent is already running. Please shut down uTorrent and try again"

After shutting down uTorrent and opening it again, the same message is displayed.

The Fix:
The issue appears to be related to uTorrent getting confused about which version it has installed, and wants to run.

Make sure uTorrent has been closed (you may need to kill the task from Task Manager)

Go to the uTorrent installation directory (usually %appdata%\uTorrent or C:\users\%username%\appdata\roaming\uTorrent) and delete the Updates folder (and everything within it). If you get an error advising the files are locked/cannot be opened, you will either need to kill the stuck uTorrent process from Task Manager, or simply restart your computer.

Try starting uTorrent again after removing the Updates folder - it should now open correctly

Tuesday, 20 September 2016

iTunes Artist Icons/Thumbnails Missing

It appears there is a bug (or new feature) in the latest version of iTunes (12.5) and iOS 10 where a majority of artist icons/thumbnails/images for missing when in the Library > Artists view, as per the screenshots below - they only show a generic microphone icon/thumbnail.





I haven't been able to find a setting/option to fix this at the moment. After doing some research I'm certainly not the first person to notice this "bug".

Only "workaround" for the issue currently is to not use the artist view and instead use the "Albums" or "Songs" view which show album artwork correctly and do not utilize artist images.

Let me know in the comments if you've noticed this bug as well, or if you have found a solution. I'll continue searching and will keep this posted updated with any fixes I find.

Update: I've found an apple discussion thread that states that the artist photo only shows up if you've purchased an album from that artist from the Apple Music store.

https://discussions.apple.com/thread/7663488?start=0&tstart=0


IP Address/Ping Monitoring using Powershell

Here is a script I developed to monitor/check the online availability of an IP address using powershell. I've set this script to run every 10 minutes to check that a device on my network (WDTV Live) is online as it had a tendency to go offline occasionally.

$ip = the IP address you wish to monitor
$ping = utilises the test-connection cmdlet to attempt to contact the IP address (specified in $ip) using ICMP (ping) packets

If the ping test does not return a result (ie. the IP address does not respond), a "flag" is placed in the form of a file called "WDTV.Offline". This flag file is used/checked by the script to prevent repeat notifications being sent after the first notification that the device is offline (or is back online after previously being offline)

If the ping test does return a result (ie. the IP address responded to the ping request), the script checks to see if it was previously offline (by looking for the flag file mentioned previously). If the flag file is found, another notification is sent advising the device is now back online, and the flag file is deleted. This means the next time the script runs, if the device is still online and no flag file is present, no further notifications are sent


$ip = "192.168.0.150"
$ping = test-connection $ip -count 2

if (!$ping)
    {
    $flagtest = test-path "D:\Powershell\WDTV.Offline"
    if ($flagtest -eq $false)
        {
        new-item "D:\Powershell\WDTV.Offline" -type file
        $from = "user@gmail.com"
        $to = "user@gmail.com"
        $subject = "$ip Offline"
        $body = "$ip not responding to ping"
        $smtp = New-Object System.Net.Mail.SmtpClient("smtp.gmail.com", "587");
        # Uncomment the below row if your ISP´s outgoing mail server requires authentication.
        $smtp.EnableSSL = $true
        $smtp.Credentials = New-Object System.Net.NetworkCredential("username", "password");
        $smtp.Send($From, $To, $subject, $body);
        #write-host "Mail Sent"
        }
    }

elseif ($ping)
    {
    $flagtest = test-path "D:\Powershell\WDTV.Offline"
    if ($flagtest -eq $true)
        {
        remove-item "D:\Powershell\WDTV.Offline"
        $from = "user@gmail.com"
        $to = "user@gmail.com"
        $subject = "$ip Online"
        $body = "$ip now responding to ping"
        $smtp = New-Object System.Net.Mail.SmtpClient("smtp.gmail.com", "587");
        # Uncomment the below row if your ISP´s outgoing mail server requires authentication.
        $smtp.EnableSSL = $true
        $smtp.Credentials = New-Object System.Net.NetworkCredential("username", "password");
        $smtp.Send($From, $To, $subject, $body);
        #write-host "Mail Sent"
        }
    }

You will need to update the $from, $to and username/password fields within the $smtp.credentials variables in order for the email notifications to work, as well as the values for outgoing mail server and port within the System.Net.Mail.SmtpClient

You can refer to my previous blog post Here which contains some more information about sending SMTP emails using authentication with powershell

Monday, 19 September 2016

iTunes could not connect to the iPhone because an invalid response was received from the device

I encountered this issue on my home PC after getting my new iPhone 7. I had previously sync'd the phone with my laptop, but upon connecting it to my PC, I got the error message;

"iTunes could not connect to the iPhone because an invalid response was received from the device"

I was pretty confident the phone wasn't the issue as it had successfully sync'd with another computer - I tried the following steps first which did not fix the issue;


  • Different USB/lightning cable
  • Different USB port
  • Rebooted computer
  • Rebooted iPhone
  • Ensured iPhone wasn't locked when connecting
  • Removed iPhone device from device manager
What ended up fixing the issue in the end was uninstalling and re-installing iTunes on the computer.

Apple iOS 10 Home Button Unlock Fix - iPhone iPad

In the latest update to Apple's iPad/iPhone operating system (iOS 10), they have changed the behaviour of the lock screen.

You now need to press the home button your device in order to unlock it. There is a way however, to enable the functionality we had before iOS 10, where holding your finger on the home button (without pressing it) will unlock the device as well.

The option is somewhat hidden within the settings. To access it, do the following;

Go to Settings > General > Accessibility > Home Button and enable the option to Rest Finger to Open