Jump to content


  • Content Count

  • Joined

  • Last visited

About David-

  • Rank
    IT Apprentice

Profile Information

  • Location
    Midland Michigan
  1. 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
  2. Adding one line hides the ID from the user. $Username = "ID to create" $Password = "Password for created ID" $group = "Administrators" $adsi = [ADSI]"WinNT://$env:COMPUTERNAME" $existing = $adsi.Children | where {$_.SchemaClassName -eq 'user' -and $_.Name -eq $Username } if ($existing -eq $null) { Write-Host "Creating new local user $Username." & NET USER $Username $Password /add /y /expires:never Write-Host "Adding local user $Username to $group." & NET LOCALGROUP $group $Username /add New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\SpecialAccounts\UserList" -Name $Username -PropertyType DWord -Value 0 -ea SilentlyContinue -wa SilentlyContinue } else { Write-Host "Setting password for existing local user $Username." $existing.SetPassword($Password) } Write-Host "Ensuring password for $Username never expires." & WMIC USERACCOUNT WHERE "Name='$Username'" SET PasswordExpires=FALSE exit 0; I have not used created ID to run scripts. Wanted to give back, if I didn't post this now I would never post it. I am new to scripting with pulseway. Does Write-Host go somewhere meaningful, or is this just also a script you manually run? Thanks for the ID creation with error checking!
  3. 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?
  • Create New...