This is where I know my environment enough that I know I will grab the right file. I am using two conditions to make sure I grab the appropriate shortcut: The file ends with. If it is online, check for the shortcut file in the C:\Users\Public\Desktop folder. This will return either a True or False result.)
I place the workload inside a foreach loop and the task is as follows:Ĭheck to see if the PC is online using the Test-Connection cmdlet. Finally, $NewTarget is the address we want to set on the shortcut. The $Shell variable is the key to getting into manipulate the shortcut file. csv file with a list of my targeted computers inside. I won’t cover logging in depth, but you should use your preferred method of logging to get detailed feedback on this task. $Shell = New-Object -ComObject WScript.Shell $Computers = Get-Content -Path C:\Scripts\computers.csv The beginning variables are short and sweet:
I have recently set out to dig in with PowerShell, and though I do watch some videos and read my go-to book, Learn Windows PowerShell in a Month of Lunches, there’s honestly been no better learning than just starting with a simple, mundane task and work at automating it! Mass-changing the target address for a. Which has definitely helped with challenging myself in creating custom scripts for my environment. Of course, the more I dug into the task, the more I wanted to add. Search through a list of PCs and modify the target address on a specific web shortcut that pointed to an intranet page that resides on the C:\Users\Public\Desktop. I am slowly but surely utilizing GPOs to manage shared printers, mapped drives, and desktop shortcuts and settings. At the time, this was the most efficient way to deploy given the access and timelines when these were deployed. Yes, I know…any shortcuts should be deployed via Group Policy…I get it. Recently, as a part of retiring legacy Windows Server OS(s), I had to find a quick and dirty way to change the target location for a certain file in the Public desktop folder on all the machines in my environment.