
#Windows 10 powershell Pc
Next, you need to configure the TrustedHosts setting on both the PC to which you want to connect and the PC (or PCs) you want to connect from, so the computers will trust each other.
#Windows 10 powershell how to
For more on the difference-and how to change to a private network if you already have a public network set up-check out our guide on private vs. Note: For PowerShell Remoting to work in a workgroup environment, you must configure your network as a private, not public, network. Related: What's the Difference Between Private and Public Networks in Windows? You should have already enabled Remoting on the PC to which you want to connect, as we described in the previous section. To do this I dove into the Win32 API to first allow the account to elevate the tokens that I have mentioned before.If your computers aren’t on a domain, you need to perform a few more steps to get things set up. The final thing that I came up with followed a similar idea as my second attempt, but makes sure to allow for recursion and files and folders as well as allowing either ‘Builting\Administrators’ or another account to have ownership of files and folders. Well, it doesn’t quite work that way either because only the directories would propagate these permissions but the files wouldn’t get ownership. Fine, I can add those privileges if needed and continue on from there. Because the accounts do not have the proper user rights ( seTakeOwnershipPrivilege, SeRestorePrivilege and SeBackupPrivilege), this would fail right away with an ‘Access Denied’ error.

Sounds good, right? Well, not really due to some un-foreseen issues. $Group = New-Object ("Builtin", "Administrators") The next idea was to grab the ACL object of a folder elsewhere in the user’s home directory that had good permissions and then change the owner in that ACL object to ‘Builtin\Administrators” and the apply it to the profile folder. Take Ownership using PowerShell and Set-ACL

This was a huge issue and would not be acceptable with the customer. I still decided to press forward with this and later found the second issue: takeown.exe would not reliably grant ownership completely down the tree of subfolders. Obviously this is an issue if I expect to have this used as part of my project for others to take ownership on profiles which would more than likely have more items than my profile. I kicked it off on my own profile (because it is always more fun to test on yourself than others) and found that it would take upwards of 10 minutes vs. Sure it wasn’t a PowerShell approach, but it met the requirements of what I wanted to do…or so I thought. This was actually my initial idea as I allows for recursive actions and lets me specify to grant ownership to Builtin\Administrators. This created issues with deleting accounts and troubleshooting profile related issues.īefore showing the solution that I came up with, I will run down a list of attempts which never quite met my requirements and why. Also, ownership of those objects were by the user account. The brief background on this is that roaming profiles sometimes would become inaccessible to our support staff in that only the user account and System would have access to the profile folder and its sub-folders and files. But the goal was to come up with a command line solution that not only worked quickly, but didn’t miss out on a file or folder. Typically, one could use Explorer to find the folder and then take ownership and be done with it.

While working on a project recently, I needed to find an easy way to take ownership of a profile folder and its subfolders to allow our support staff to either delete the profile or be able to traverse the folder to help troubleshoot issues.
