![]() Internal const int TOKEN_ADJUST_PRIVILEGES = 0x00000020 Internal const int TOKEN_QUERY = 0x00000008 Internal const int SE_PRIVILEGE_ENABLED = 0x00000002 ![]() Internal const int SE_PRIVILEGE_DISABLED = 0x00000000 Internal static extern bool LookupPrivilegeValue(string host, string name, Internal static extern bool OpenProcessToken(IntPtr h, int acc, ref IntPtr Internal static extern IntPtr GetCurrentProcess() Ref TokPriv1Luid newst, int len, IntPtr prev, IntPtr relen) Internal static extern bool AdjustTokenPrivileges(IntPtr htok, bool disall, Script2 : Change FOLDER owner to Admin $AdjustTokenPrivileges = System $Account = New-Object ("BUILTIN\Administrators") Script1 : Change FILE owner to Admin $File = "\\server\c$\Users\dir\Downloads\Target\TargetFile.txt" How can this be combined in one script so it does all the subfoldes and files all together? Putting it in 2 different functions maybe and loop through it or. Each script only works for 1 file or 1 folder.to change the owner of all files and subfolders to BUILTIN\Administrators.Run one script on \\server\C$\Folder (without using external tools).Now I'm trying to combine both so they work recursively, because we have folders with over 500 sub directories and files in them. When testing this, it functions perfectly in PowerShell 1.0. Searching the web, I found 2 scripts that are able to change the owner of files and folders.
0 Comments
Leave a Reply. |