Starting your programs with different credentials using a Powershell script

I always start the same programs at work. Because I login with a normal user account, I start most of them with my admin credentials. This took me too much time to do at each startup, also because of the hard to type password. So I wrote a Powershell script 🙂 Maybe it can be of some use to you.

I got some trouble starting MMC modules, but got it to work eventually. Using 8dot3 paths to bypass space-in-path problems.

# —————————————————————————–
# Script: Start-Processes.ps1
# Author: Yuri de Jager, https://yuridejager.wordpress.com
# Date: 2013-11-27
# Keywords: Scripting Techniques, Processes, MMC modules
# comments: Start tools with admin account.
# Start-Process, Get-Content
# YdJ – 2013-11-27
# —————————————————————————–
# First save password in password file. Run only when password changes
# $credentials = Get-Credential
# $credentials.Password | ConvertFrom-SecureString | Set-Content [path to]passwd.txt

$password = Get-Content [path to]passwd.txt | ConvertTo-SecureString
$user = [admin user]
$creds = New-Object System.Management.Automation.PSCredential $user,$password

$systemroot = $env:SystemRoot
$progs = $env:ProgramFiles
$progsx86 = “${Env:ProgramFiles(x86)}”

Start-Process $systemroot\system32\mmc.exe -ArgumentList $systemroot\system32\dsa.msc -Credential $creds -windowstyle Maximized
Start-Process $systemroot\system32\mmc.exe -ArgumentList $systemroot\system32\dfsmgmt.msc -Credential $creds -windowstyle Maximized
Start-Process $systemroot\system32\mmc.exe -ArgumentList $systemroot\system32\dhcpmgmt.msc -Credential $creds -windowstyle Maximized
Start-Process $systemroot\system32\mmc.exe -ArgumentList $systemroot\system32\dnsmgmt.msc -Credential $creds -windowstyle Maximized
Start-Process $systemroot\system32\mmc.exe -ArgumentList $systemroot\system32\Cluadmin.msc -Credential $creds -windowstyle Maximized
Start-Process $systemroot\system32\mmc.exe -ArgumentList C:\Progra~1\UPDATE~1\ADMINI~1\wsus.msc -Credential $creds -windowstyle Maximized
Start-Process $systemroot\system32\mmc.exe -ArgumentList C:\Progra~1\MICROS~3\EXCHAN~1\V14\Bin\EXCHAN~1.MSC -Credential $creds -windowstyle Maximized
Start-Process -FilePath “$progs\ConEmu\ConEmu64.exe” -Credential $creds
Start-Process -FilePath “$progsx86\RobWare\RVTools\RVTools.exe” -Credential $creds
Start-Process -FilePath “$progsx86\Remote Desktop Connection Manager\RDCman.exe” -windowstyle Maximized
Start-Process -FilePath “$progsx86\VMware\Infrastructure\Virtual Infrastructure Client\Launcher\VpxClient.exe”
Start-Process -FilePath “$progsx86\MICROS~2\Office14\OUTLOOK.EXE” -windowstyle Maximized
Start-Process $systemroot\system32\cmd.exe

Advertisements

About Yuri de Jager
Technology Addict

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: