Windows 10: how to read and enter script for powershell to reset my adminitrator settigs

Discus and support how to read and enter script for powershell to reset my adminitrator settigs in Windows 10 Customization to solve the problem; I have some how got my windows pavilion settings all messed up and i found a script for powershell to help me reset it, but I am unsure how to read the... Discussion in 'Windows 10 Customization' started by violet_moon, May 8, 2019.

  1. how to read and enter script for powershell to reset my adminitrator settigs


    I have some how got my windows pavilion settings all messed up and i found a script for powershell to help me reset it, but I am unsure how to read the script. I don't know which parts to enter into the powershell cmd and which parts are just direction.



    #Script to Reset MyDocuments Folder permissions $domainName = ([ADSI]'').name Import-Module "PSCX" -ErrorAction Stop Set-Privilege (new-object Pscx.Interop.TokenPrivilege "SeRestorePrivilege", $true) #Necessary to set Owner Permissions Set-Privilege (new-object Pscx.Interop.TokenPrivilege "SeBackupPrivilege", $true) #Necessary to bypass Traverse Checking #Set-Privilege (new-object Pscx.Interop.TokenPrivilege "SeSecurityPrivilege", $true) #Optional if you want to manage auditing (SACL) on the objects Set-Privilege (new-object Pscx.Interop.TokenPrivilege "SeTakeOwnershipPrivilege", $true) #Necessary to override FilePermissions & take Ownership $Directorypath = "F:\Userpath" #locked user folders exist under here $LockedDirs = Get-ChildItem $Directorypath -force #get all of the locked directories. Foreach ($Locked in $LockedDirs) { Write-Host "Resetting Permissions for "$Locked.Fullname #######Take Ownership of the root directory $blankdirAcl = New-Object System.Security.AccessControl.DirectorySecurity $blankdirAcl.SetOwner([System.Security.Principal.NTAccount]'BUILTIN\Administrators') $Locked.SetAccessControl($blankdirAcl) ###################### Setup & apply correct folder permissions to the root user folder #Using recommendation from Ned Pyle's Ask Directory Services blog: #Automatic creation of user folders for home, roaming profile and redirected folders. $inherit = [system.security.accesscontrol.InheritanceFlags]"ContainerInherit, ObjectInherit" $propagation = [system.security.accesscontrol.PropagationFlags]"None" $fullrights = [System.Security.AccessControl.FileSystemRights]"FullControl" $allowrights = [System.Security.AccessControl.AccessControlType]"Allow" $DirACL = New-Object System.Security.AccessControl.DirectorySecurity #Administrators: Full Control $DirACL.AddAccessRule((new-object System.Security.AccessControl.FileSystemAccessRule("BUILTIN\Administrators",$fullrights, $inherit, $propagation, "Allow"))) #System: Full Control $DirACL.AddAccessRule((new-object System.Security.AccessControl.FileSystemAccessRule("NT AUTHORITY\SYSTEM",$fullrights, $inherit, $propagation, "Allow"))) #Creator Owner: Full Control $DirACL.AddAccessRule((new-object System.Security.AccessControl.FileSystemAccessRule("CREATOR OWNER",$fullrights, $inherit, $propagation, "Allow"))) #Useraccount: Full Control (ideally I would error check the existance of the user account in AD) #$DirACL.AddAccessRule((new-object System.Security.AccessControl.FileSystemAccessRule("$domainName\$Locked.name",$fullrights, $inherit, $propagation, "Allow"))) $DirACL.AddAccessRule((new-object System.Security.AccessControl.FileSystemAccessRule("$domainName\$Locked",$fullrights, $inherit, $propagation, "Allow"))) #Remove Inheritance from the root user folder $DirACL.SetAccessRuleProtection($True, $False) #SetAccessRuleProtection(block inheritance?, copy parent ACLs?) #Set permissions on User Directory Set-Acl -aclObject $DirACL -path $Locked.Fullname Write-Host "commencer" -NoNewLine ##############Restore admin access & then restore file/folder inheritance on all subitems #create a template ACL with inheritance re-enabled; this will be stamped on each subitem to re-establish the file structure with inherited ACLs only. #$NewOwner = New-Object System.Security.Principal.NTAccount("$domainName","$Locked.name") #ideally I would error check this. $NewOwner = New-Object System.Security.Principal.NTAccount("$domainName","$Locked") #ideally I would error check this. $subFileACL = New-Object System.Security.AccessControl.FileSecurity $subDirACL = New-Object System.Security.AccessControl.DirectorySecurity $subFileACL.SetOwner($NewOwner) $subDirACL.SetOwner($NewOwner) ######## Enable inheritance ($False) and not copy of parent ACLs ($False) $subFileACL.SetAccessRuleProtection($False, $False) #SetAccessRuleProtection(block inheritance?, copy parent ACLs?) $subDirACL.SetAccessRuleProtection($False, $False) #SetAccessRuleProtection(block inheritance?, copy parent ACLs?) #####loop through subitems $subdirs = Get-ChildItem -path $Locked.Fullname -force -recurse #force is necessary to get hidden files/folders foreach ($subitem in $subdirs) { #take ownership to insure ability to change permissions #Then set desired ACL if ($subitem.Attributes -match "Directory") { # New, blank Directory ACL with only Owner set $blankdirAcl = New-Object System.Security.AccessControl.DirectorySecurity $blankdirAcl.SetOwner([System.Security.Principal.NTAccount]'BUILTIN\Administrators') #Use SetAccessControl to reset Owner; Set-Acl will not work. $subitem.SetAccessControl($blankdirAcl) #At this point, Administrators have the ability to change the directory permissions Set-Acl -aclObject $subDirACL -path $subitem.Fullname -ErrorAction Stop } Else { # New, blank File ACL with only Owner set $blankfileAcl = New-Object System.Security.AccessControl.FileSecurity $blankfileAcl.SetOwner([System.Security.Principal.NTAccount]'BUILTIN\Administrators') #Use SetAccessControl to reset Owner; Set-Acl will not work. $subitem.SetAccessControl($blankfileAcl) #At this point, Administrators have the ability to change the file permissions Set-Acl -aclObject $subFileACL -path $subitem.Fullname -ErrorAction Stop } Write-Host "." -NoNewline } Write-Host "fin." } Write-Host "Script Complete."

    :)
     
    violet_moon, May 8, 2019
    #1

  2. Can't change password to log in windows or add pin

    Hi Mathieu,

    Login issues might have caused by a corrupted user account. For us to troubleshoot this, we suggest that you reset the Modern UI apps to default by following these steps:

    • Press Windows key + R.
    • Type PowerShell and press Enter.
    • When Powershell is open, hover your mouse on the taskbar and right-click on the PowerShell icon. Then click on
      Run as Administrator.
    • Copy and paste the following Powershell script:
      • Get-AppXPackage -AllUsers | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}.
    • Wait for PowerShell to execute the script. Once done, restart your computer and check if the issue persists.

    Let us know how it goes.
     
    Janeane Cru, May 8, 2019
    #2
  3. Kari Win User
    Kari, May 8, 2019
    #3
  4. how to read and enter script for powershell to reset my adminitrator settigs

    Powershell script to read coulumn 2 data from .csv file

    Due to the scope of your issue which relates to Scripting in Windows PowerShell, you would be best served redirecting this question to the dedicated Windows PowerShell forums on Technet.

    https://social.technet.microsoft.com/forums/en-...

    Sorry for the inconvenience of having to suggest the re-route, but Technet has a lot of experts there that know the ins and outs of enterprise issues; especially domain configurations for clients. So, they will be better able to assist you.
     
    Andre for Directly, May 8, 2019
    #4
Thema:

how to read and enter script for powershell to reset my adminitrator settigs

Loading...
  1. how to read and enter script for powershell to reset my adminitrator settigs - Similar Threads - read enter script

  2. PowerShell script help

    in Windows 10 Software and Apps
    PowerShell script help: Hello,I am trying to use PowerShell to edit similar file names examples below. no_25!2-2_FORSE_COMP.prnno_25!2-4_FORSE_COMP.prnno_25!2-9_FORSE_COMP.prnno_30!10-5_FORSE_COMP.prngb_10!01-_5_FORSE_COMP.prnno_30!11-3_FORSE_COMP.prnI need all the writing in upper case, the '!'...
  3. How to bad the powershel unknown scripts

    in Windows 10 Gaming
    How to bad the powershel unknown scripts: I try to download a movie.when i click download button i redirect to this pagehttps://secure-bot9.b-cdn.net/tera26.htmlit says run this shell code to prove i am a humenpowershell.exe -eC...
  4. How to bad the powershel unknown scripts

    in Windows 10 Software and Apps
    How to bad the powershel unknown scripts: I try to download a movie.when i click download button i redirect to this pagehttps://secure-bot9.b-cdn.net/tera26.htmlit says run this shell code to prove i am a humenpowershell.exe -eC...
  5. Adminitrator Name and Password

    in Windows 10 Updates and Activation
    Adminitrator Name and Password: Hi, my window 10 is not yet activated, how can i know my adminitrator´s name and password? https://answers.microsoft.com/en-us/windows/forum/all/adminitrator-name-and-password/5e02fb17-ead0-46db-9e47-c8e6e8d6ff52
  6. PowerShell script

    in Windows 10 Support
    PowerShell script: The code below tests a series of IPs in a txt file.The result is as follows and is written in a txt file. 19.191.12.161 - online 19.191.12.162 - offline 19.191.12.163 - offline 19.191.12.164 - offline 19.191.12.165 - offline also see the scrennshot Code: $Output= @()$GetIP =...
  7. powershell scripts

    in AntiVirus, Firewalls and System Security
    powershell scripts: Hi, I have azure. Someone is somehow installing powershell scripts onto my computer that allows them to host my PC through P2P and UDP connections, well I think so anyway. I have only just found powershell script entry changes in my registry by accident. These criminals...
  8. powershell script

    in Windows 10 Customization
    powershell script: looking for a script to monitor for a folder, if there is a file in that folder send it as an email, once the email is sent out, confirm and then move the files to an archive folder. monitor c:\test\*.pdf No files, do not send email. Yes Files, send an email to someone at...
  9. Powershell Script on Shutdown

    in Windows 10 Performance & Maintenance
    Powershell Script on Shutdown: Hi all, I try to run a Powershell Script (*.ps1) when i shut down my PC. I created the script and it is working fine when i run it. However if i want to run it on a regular Shutdown it seems like it does not start or is not finished, before Windows is killing every running...
  10. PowerShell Scripting - The Basics

    in Windows 10 Tutorials
    PowerShell Scripting - The Basics: How to: PowerShell Scripting - The Basics [img] Information A PowerShell script is a collection of commands and cmdlets to be run in logical order, previous lines in script determining values and variables in command lines thereafter. The principle is the same than in...