I'm trying to create a PS script, ultimately, that will find all the URL on a list of pc's, then based on if a target is found, change that target to a new target. The problem I'm having is that it is listing only the .url's of the first pc. Any help is appreciated!
function Get-DesktopShortcuts
{
$Shortcuts = Get-ChildItem ~\desktop\ -Recurse -force -include *.url
$Shell = New-Object -ComObject WScript.Shell
$strComputer = Get-Content C:\ps\test.txt
foreach ($computer in $strComputer)
{
foreach ($Shortcut in $Shortcuts)
{
$Properties = @{
Computer = $computer
ShortcutName = $Shortcut.Name
Target = $Shell.CreateShortcut($Shortcut).targetpath
}
New-Object PSObject -Property $Properties
}
}
[Runtime.InteropServices.Marshal]::ReleaseComObject($Shell) | Out-Null
}
$Output = Get-DesktopShortcuts
$Output
## $Output | Export-Csv C:\ps\smfpc.csv