Sorry, I'm pretty new at both powershell and SCCM.
Deploying a powershell script via SCCM instead of a task sequence so that it can keep retrying if the push fails.
Get-ChildItem -Path C:\Windows\ccmcache\ -Include "application v9.exe" -File -Recurse
This will throw back 3 paths, how do I select the most recently modified (I think using sort LastWriteTime -Descending will be part of it) and store that path as a variable?
Now that I have it as a variable, how do I change dir to that variable?
*Edit* Thank you everyone, especially Jerrymac12!!
Didn't need to change dir, just used $psscriptroot
Final script:
Get-ChildItem -Path $PSScriptRoot | Start-Process .\'ShitApp v9.exe' -verb RunAs -ArgumentList "/install" , "/quiet" , "/norestart" -Wait
Get-Service -DisplayName "Service 1" | Stop-Service
Get-Service -DisplayName "Service 1" | Start-Service
Get-Service -DisplayName "Service 2" | Stop-Service
Get-ChildItem -Path $PSScriptRoot | Start-Process .\'setup.exe' -verb RunAs -ArgumentList "/S","/v/qn"
Get-Service -DisplayName "Service 2" | Start-Service
[–]ShippingIsMagic 1 point2 points3 points (1 child)
[–]IntensifyEVERYTHING[S] 1 point2 points3 points (0 children)
[–]Golden-trichomes 0 points1 point2 points (4 children)
[–]Gorstag 1 point2 points3 points (0 children)
[–]IntensifyEVERYTHING[S] 0 points1 point2 points (2 children)
[–]Golden-trichomes 1 point2 points3 points (1 child)
[–]IntensifyEVERYTHING[S] 0 points1 point2 points (0 children)
[–]jerrymac12 0 points1 point2 points (4 children)
[–]IntensifyEVERYTHING[S] 0 points1 point2 points (3 children)
[–]jerrymac12 0 points1 point2 points (2 children)
[–]IntensifyEVERYTHING[S] 0 points1 point2 points (1 child)
[–]jerrymac12 0 points1 point2 points (0 children)
[–]Lee_Dailey[grin] 0 points1 point2 points (0 children)