Hi,
I want to run the below script with admin rights,
$Threshold = -90
$UserProfileFolders = Get-ChildItem "$($env:SystemDrive)\Users" | ? { $_.LastAccessTime -lt ((Get-Date).AddDays($Threshold)) } | Select Name,FullName,LastAccessTime
$WmiUserProfiles = Get-WmiObject Win32_UserProfile
$WmiUserProfiles | % {
if (($UserProfileFolders | Select -Expand FullName) -contains $_.LocalPath) {
$_.Delete()
}
}
if run the below command on powershell, it would open the new window with admin rights,
Start-Process powershell -Verb runAs
But i want to run the above script on that newly opened window through scripting itself without manually copying and pasting it on the new window
Could you please provide some insights how to do it?