Scripting Question

PS script for shortcut

06/21/2016 1003 views

 I wrote a script in Wscript but , new to PS. Please can some one guide me. The Script should look at AD and if present look in which location its added and then create shortcut for that location

set Variable GrpName to

Parse String "%grpname%" into GRP and LCTN

set Variable GRP to %GRP%

set variable LCTN to %LCTN%

set variable PRF to C:\Program Files (x86)

set variable XYZ to %PRF%\ABC\DEF

set config to \\srvrlocatn

set config to %config%\Lctn

set config1 to \\inilocatn

Read ini value from %config%IPA.ini into variable IPA

Get Environmental Variable PROGRAMDATA into Variable PROGRAMDATA

set Variable IEXPLORER to C:\program files (x86)\Interenet Explorer\iexplore.exe

If LCTN Equals "NYC" then

create shortcut from %IEXPLORER% to %programdata%\ABCshortcut_NYC

Thank you

Answer Summary:
1 Comment   [ + ] Show comment


  • Is this to be run on start-up for each system? If so you would be better to start looking though WMI.

    This will get you kicking just replace FQDN with your FQDN and see how that goes for a starter.

    All this does is looks at the WMI of the system and pulls information stored there.

    get-wmiobject win32_ntdomain | Where-Object -FilterScript {$_.DNSForestName -eq 'FQDN'} | select *

    If this has the information you want we can then narrow it down to a single item and make it into a variable based on the word.

Answer Chosen by the Author


This will write the shortcut

$DestinationPath = 'C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Blah IE.lnk'
$SourceExe = 'C:\program files (x86)\Interenet Explorer\iexplore.exe'
$ArgumentsToSourceExe = 'http://blah.com'

$WshShell = New-Object -ComObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut($DestinationPath)
$Shortcut.TargetPath = $SourceExe
$Shortcut.Arguments = $ArgumentsToSourceExe
Answered 06/22/2016 by: rileyz
Red Belt

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

View more:


This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ