David- Posted September 24, 2018 Share Posted September 24, 2018 Would like to execute powershell and batch scripts as admin. Is this possible? For example, I would like to run sfc. Is my only option scheduling tasks? Link to comment Share on other sites More sharing options...
Staff Chris Posted October 4, 2018 Staff Share Posted October 4, 2018 Hi, Have you tried to configure the PowerShell impersonation from the Pulseway Manager on the remote system? Link to comment Share on other sites More sharing options...
David- Posted June 29, 2019 Author Share Posted June 29, 2019 I have been unable to get the vast majority of my powershell scripts to run. Scripts that run with no issues when run locally. Many that do not require admin access. I have tried running them without power shell user impersonation enabled. I have attempted creating and using an ID that is part of the administrator group. Enabling the administrator ID than using it as ps user impersonation. I've verified user impersonation settings in registry are correct. No errors are being registered in pulseway. I am testing on a system that does not have a domain. So I have left that field blank. Just in case I attempted to fill it with the system name a few times. My ultimate goal would be to use the administrator to run commands. I am willing to accept running as a user that is part of the admin group. An example of a script I am certain works, but now through pulseway. ## Enable Storage Sense ## Ensure the StorageSense key exists $key = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\StorageSense" If (!(Test-Path "$key")) { New-Item -Path "$key" | Out-Null } If (!(Test-Path "$key\Parameters")) { New-Item -Path "$key\Parameters" | Out-Null } If (!(Test-Path "$key\Parameters\StoragePolicy")) { New-Item -Path "$key\Parameters\StoragePolicy" | Out-Null } ## Set Storage Sense settings ## Enable Storage Sense Set-ItemProperty -Path "$key\Parameters\StoragePolicy" -Name "01" -Type DWord -Value 1 ## Set 'Run Storage Sense' to Every Week Set-ItemProperty -Path "$key\Parameters\StoragePolicy" -Name "2048" -Type DWord -Value 7 ## Enable 'Delete temporary files that my apps aren't using' Set-ItemProperty -Path "$key\Parameters\StoragePolicy" -Name "04" -Type DWord -Value 1 ## Set 'Delete files in my recycle bin if they have been there for over' to 14 days Set-ItemProperty -Path "$key\Parameters\StoragePolicy" -Name "08" -Type DWord -Value 1 Set-ItemProperty -Path "$key\Parameters\StoragePolicy" -Name "256" -Type DWord -Value 30 ## Set 'Delete files in my Downloads folder if they have been there for over' to 60 days #Set-ItemProperty -Path "$key\Parameters\StoragePolicy" -Name "32" -Type DWord -Value 1 #Set-ItemProperty -Path "$key\Parameters\StoragePolicy" -Name "512" -Type DWord -Value 60 ## Set value that Storage Sense has already notified the user Set-ItemProperty -Path "$key\Parameters\StoragePolicy" -Name "StoragePoliciesNotified" -Type DWord -Value 1 Link to comment Share on other sites More sharing options...
Staff Chris Posted July 1, 2019 Staff Share Posted July 1, 2019 Hi @David-, From your script I can see that you are trying to set the HKCU registry keys which are for the currently user account, therefore in order to set these keys for the required user account the powershell impersonation is required. If it is not configured, the the HKCU keys will be set for the System account and it will not affect the required user session. Link to comment Share on other sites More sharing options...
DCPC Tech Posted July 9, 2022 Share Posted July 9, 2022 Hi I was trying this but i can't get to apply the registry. I have added the a local admin user and added this user to powershell impersonation in pulseway manager. any ideas please? thanks Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now