Jan 302014
Pin It

Sometimes you may have a SID (objectSid) for an Active Directory object but not necessarily know which object it belongs to. You can find the object using PowerShell.

I came across this when recovering a hard drive for a company. The hard drive was from a domain computer and the NTFS permissions only showed the SID as the recovery computer was a workgroup computer and didn’t have access to the domain. I wanted to re-apply the NTFS permissions on the replaced drive so I needed to know which each SID belonged to.

Run the following on a computer that is a member of the domain:

Import-Module ActiveDirectory
Get-ADUser -Identity S-1-5-21-941005169-1824062477-405670111-1106
Pin It
Mar 022013
Pin It

I’ve been thinking about building a plugin for MPD that would allow it to talk with Google Music for a while now. Currently, when I purchase music from Google Music, I have to download it and push the new music up to my local music share on my network. Once my music is there, MPD can stream it without a problem… I love MPD!

I started to investigate the idea this weekend. I found these two projects that I wanted to share with you guys. They helped me prove out that the plugin I want to write is possible without TOO much work.

Unofficial Google Music API – An unofficial, opensource API written in Python for Google Music.
MPC – A linux terminal based MPD client.

First, by modifying the example.py in the Google Music API a little I was able to create a script that would sign into Google Music, find the first song in my library and grab the streaming URL of that song.

#!/usr/bin/env python
# -*- coding: utf-8 -*-

from getpass import getpass
from gmusicapi import Api

def ask_for_credentials():
    """Make an instance of the api and attempts to login with it.
    Return the authenticated api.

    api = Api()

    logged_in = False
    attempts = 0

    while not logged_in and attempts < 3:
        email = raw_input("Email: ")
        password = getpass()

        logged_in = api.login(email, password)
        attempts += 1

    return api

def demonstration():
    """Demonstrate some api features."""

    api = ask_for_credentials()

    if not api.is_authenticated():
        print "Sorry, those credentials weren't accepted."

    print "Successfully logged in."

    #Get all of the users songs.
    #library is a big list of dictionaries, each of which contains a single song.
    print "Loading library...",
    library = api.get_all_songs()
    print "done."

    print len(library), "tracks detected."

    #Show some info about a song. There is no guaranteed order;
    # this is essentially a random song.
    first_song = library[0]
    print "The first song I see is '{}' by '{}'.".format(

    #We're going to create a new playlist and add a song to it.
    #Songs are uniquely identified by 'song ids', so let's get the id:
    song_id = first_song["id"]
    print (api.get_stream_url(song_id))

    #It's good practice to logout when finished.
    print "All done!"

if __name__ == '__main__':

When running the script above, it’ll ask for a Google account and password. Once they are entered the script will login and load the library of the account. It will grab the first song in the library and output the URL to stream the song. Now that I had the streaming URL, I needed a way to add that to my MPD queue.

mpc clear
mpc play

Low and behold! When I hit play the song started playing! So now we know that it can work the next step is figuring out if there’s a way to tie the Google Music library in with MPD’s library.

Pin It
Feb 252013
Pin It

I came across a situation last week where I needed to finally disable NetBIOS over TCP/IP. While looking for a way to disable it, unfortunately, I found that there really isn’t a good clean way to do so using Group Policy. At least, if there was a good way, I couldn’t find it.

What I came up with was a VBScript that disables NetBIOS over TCP/IP for every NIC in a computer. The script can be easily modified to enable NetBIOS over TCP/IP as well. I’m currently using this as a Computer Startup Script. Once the script is run, the effects should take place on the next reboot.

A screenshot of the settings the script modifies.

The screenshot above shows you the settings we’re modifying. Use this as a reference so you know which line to uncomment in the script. By default I have the script set to 2 – Disable NetBIOS over TCP/IP.

'  Title:      Configure NetBIOS over TCP/IP
'   Date:      2/25/2013
' Author:      Gregory Strike
'    URL:      http://www.gregorystrike.com/2013/02/25/configure-netbios-over-tcpip-group-policy/
'Purpose:      The following script will itterate through all NICs on a computer
'              to configuure NetBIOS over TCP/IP.  It finds the NICs listed under:
'              HKLM\SYSTEM\CurrentControlSet\services\NetBT\Parameters\Interfaces
'              For each NIC under the key, it sets the NetbiosOptions value to one
'              of the below.  (Be sure to uncomment the setting you desire.)
'              0 - Default: Use DHCP setting from the DHCP Server
'              1 - Enable NetBIOS over TCP/IP
'              2 - Disable NetBIOS over TCP/IP
'License:      This script is free to use given the following restrictions are followed.
'              1. When used the Author and URL above must remain in place, unaltered.
'              2. Do not publish the contents of this script anywhere. Instead a link
'                 must be provided back to the URL listed above.
'Requirements: Administrative Privileges

const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."
Set ObjWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")

'Set the path to the Network Interfaces
strKeyPath = "SYSTEM\CurrentControlSet\services\NetBT\Parameters\Interfaces"

'Get all the known interfaces
ObjWMI.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys

'If there was a problem getting strKeyPath, exit the script before throwing an error.
If IsNull(arrSubKeys) Then WScript.Quit

WScript.Echo Now() & " - Searching for Network Adapaters."

'Loop through all Network Interface Cards and disable NetBIOS over TCP/IP
For Each Adapter In arrSubKeys
	WScript.Echo Now() & " - Disabling NetBIOS over TCP/IP on '" & Adapter & "'"

	'Default: Use DHCP setting from the DHCP Server
	'objWMI.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath & "\" & Adapter, "NetbiosOptions", 0

	'Enable NetBIOS over TCP/IP
	'objWMI.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath & "\" & Adapter, "NetbiosOptions", 1

	'Disable NetBIOS over TCP/IP
	objWMI.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath & "\" & Adapter, "NetbiosOptions", 2

WScript.Echo Now() & " - Completed."


Pin It