Stop loading iTunes

Yeah I am an iPhone user these days. No I don’t need to have the software installed but I installed it. Now when I plug my phone in, just to charge, stupid iTunes loaded. I have a ton of windows open pushing my laptop to the max so sometimes clicking on the x to close the window just doesn’t work… my new favorite one-liner is now…

(Get-Process -Name iTunes).Kill()

So of course I took this and added it to my profile.ps1

function kill-itunes
{
    [CmdletBinding()]
    param ()
    (Get-Process -Name itunes).Kill()
}
Advertisements

Home Drive Mapping

So, this one is quick and was primarily meant to be a quick example when presenting on the Quest AD cmdlets.  The practical piece is to deal with something we experience when working remotely.  Typical scenario, user logs in locally to their laptop and then connect to the corporate network via VPN.  The home drive is not mapped because when the desktop state is loaded the VPN connection has not yet been made.  So the script showed how to add a little function to their powershell profile so they could simply run the function to make their connection.

function map-homedrive {

# simple function to map the drive based on your user info

$nw = New-Object -ComObject Wscript.Network

$nw.MapNetworkDrive((Get-QADUser $env:USERNAME).HomeDrive, (Get-QADUser$env:USERNAME).HomeDirectory)

}

The script simply  determines the current user name ($env:USERNAME), then reads the configured values for the corresponding Active directory object for the drive letter (Get-QADUser $env:USERNAME).HomeDrive and then the path (Get-QADUser $env:USERNAME).HomeDirectory , combining those two values to perform the drive mapping.