Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Beginner question on "If" statement

$
0
0

Hello and I hope my question isn't too basic for this forum. I came up with a simple script that copies a standard set of shortcuts from a server file share to the all user's desktop. I only want our VPN shortcut to be placed on the desktop of laptop and tablet computers, so I used two "If" statements that copy this shortcut if the 4th and 5th letter of the computer name are LT or TB. The script works fine until it hits the first If statement. At that point it assigns LT as the value for $computertype rather than copying the shortcut if $computertype is equal to LT. 

$computertype=$env:COMPUTERNAME.Substring(3,2)

copy-item-Path"\\server\Package_Source_Files\Shortcuts\Aware\Aware Production.url"-Destination"C:\users\Public\Desktop"-Force

copy-item-Path"\\server\Package_Source_Files\Shortcuts\DES\Employee Self Service.url"-Destination"C:\users\Public\Desktop"-Force

Copy-Item-Path"\\server\Package_Source_Files\Shortcuts\DES\Learning Management System SSO.url"-Destination"C:\users\Public\Desktop"-Force

Copy-Item-Path"\\server\Package_Source_Files\Shortcuts\DES\TEMS.url"-Destination"C:\users\Public\Desktop"-Force

Copy-Item-Path"\\server\Package_Source_Files\Shortcuts\System 7\System 7.url"-Destination"C:\users\Public\Desktop"-Force

If ($computertype="LT") {copy-item"\\server\Package_Source_Files\Shortcuts\F5\DSB VPN.url"-Destination"C:\Users\Public\Desktop"-Force}

If ($computertype="TB") {Copy-Item"\\server\Package_Source_Files\Shortcuts\F5\DSB VPN.url"-Destination"C:\Users\Public\Desktop"-Force}


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>