Тёмный

Change File/Folder permissions with Powershell 

Code Doge
Подписаться 1,9 тыс.
Просмотров 17 тыс.
50% 1

Please follow me on Twitter to get more updates on memes, tech news, devops/developer content!
/ codedoge4
#powershell #security #scripts #scripting #programming
Important Time Stamps :
00:00 - Intro
00:10 - How to add user to a file or folder manually
01:03 - Intro Access Control List or Get-ACL
01:27 - Reminder that link to files are in video description and github
01:39 - Start scripting for ACL
02:54 - Filling in variables
03:12 - Inspecting folder permissions prior to script execution
03:30 - Brief overview of ACL and parameters required
04:33 - Additional Variables to create
05:03 - Creating the argument list variable
05:26 - Adding the argumentlist parameter to command
05:33 - running script with ACL and seeing the result of adding a user or security group to a folder or file
06:02 - Why you might NOT want to use ACL method
06:45 - Intro with using ICACLS.exe
07:24 - Getting started with ICACLS
07:41 - Initial variable values
08:19 - Detail breakdown of the parameters for ICACLs method
09:12 - Executing the powershell script with ICACLS method
10:03 - Running the script with ICACLs method
10:34 - Outtro
Github Link :
github.com/jc566/RU-vid_Solu...
Important Links :
ACL Commandlet
docs.microsoft.com/en-us/powe...
File System Rights parameters
docs.microsoft.com/en-us/dotn...
ICACLS Documentation and breakdown
#ss64.com/nt/icacls.html
Official Microsoft ICACLS.exe documentation
#docs.microsoft.com/en-us/wind...
This video covers how to use modify or set the security settings or permissions to a file or folder using ACL as well as ICACLS.
Ignore the next chunk of text as its to get picked up in searches.
Modify file security settings
Modify folder security setings
Set file permissions
Set folder permission
Change file permission
Change folder permission
Give access to folder
Give access to file
Set security group for folder
Set security group for file
How to change file permissions
How to change folder permissions
How to set file and folder permissions windows
Fix "You don't currently have permission to access this folder"
How to set permissions Windows Server 2016
How to set folder permissions
How to set file permissions
We cover how to set security permissions for folders using powershell. There are 2 method that we use for this security permissions video which is using Access Controll List aka ACL or ICACLS.exe
Both Get-ACL and ICACLS.exe are viable and are good for different scenarios for changing security permissions on folder using powershell.
Personally, I like using ICACLS because the machine or host server invoking the powershell doesnt need to have priviliged access rights.
I did experience in the line of work where using ACL required higher admin rights in order to invoke, may have been a one off thing or something else I did poorly on my end, but safe to say 60% of the time ICACLS works everytime.
Hopefully this video on setting permissions / changing security rights for a folder or file using powershell is helpful for you.
Also if you actually read this video description, you will notice that I spammed security settings, permissions, powershell, folder rights, folder access rights, etc because I want this to get picked up.
I apologize for the boring video description on security settings, folder access rights and how to modify them, also how to modify folder permissions.
As a reward for actually reading this video description, I shared a game code that is redeemable on steam for The Walking Dead by Telltale games.
But before you get to that, there is one more line of punishment for filling in search criteria based on folder permissions, setting folder permissions, changing folder permissions, modifying folder permissions, changing access rights, setting access rights for folders, and powershell keywords.
Here is the steam code : C95JP-GM66P-Z7IJA
If you redeemed it, please leave a comment on the video notifying everyone that you redeemed the game code so others can save their time.
And again, thanks for watching this video covering how to modify folder access rights, change security rights, access permissions, or any variation of how to change folder access rights.
Also if you are interested in how to use Steam Achievement Manager to unlock steam achievements, please watch my other video : • How to Unlock Any Stea...
One last time, this is for changing folder access rights or changing folder permissions using powershell.
Okay Ill stop with the spam.
Why are you still reading this video description? You already got the reward potentially.
Stop reading at this point, you poor soul. Thanks for watching and reading!!!

Опубликовано:

 

30 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 54   
@Momofoxer
@Momofoxer 2 года назад
Man you're awesome. The last few days I was working to make this and all the pages, forums, blogs... didn't solve my problem. Thanks for make this video and explain soo well how to use this method, finally the icacls method worked super
@CodeDoge
@CodeDoge 2 года назад
I prefer the icacls method over the powershell module too. I had instances with ancient servers where powershell module was not an option so ICACLs was the clutch factor. Anyways, glad it helped!
@RonanONeill-rj9qv
@RonanONeill-rj9qv Год назад
not a programmer but I followed it and to my surprise works
@CodeDoge
@CodeDoge Год назад
Im so happy to hear this! glad it helped!
@cylee604
@cylee604 3 года назад
This is SUPER helpful! #1 fan... for all your videos.......
@CodeDoge
@CodeDoge 3 года назад
You're the best!
@deckpeck3002
@deckpeck3002 2 года назад
omg u really need a raise buddy. love your work ,keep it up
@CodeDoge
@CodeDoge 2 года назад
haha I'd like to introduce you to my boss and if you could just repeat that same sentence, thatd be great! Glad you found it helpful!
@deckpeck3002
@deckpeck3002 2 года назад
@@CodeDoge lmao
@prestigequickcod
@prestigequickcod 4 месяца назад
thank you so much i literaaly watched the first 21 seconds and got the help i needed! New Sub
@CodeDoge
@CodeDoge 4 месяца назад
so glad it was helpful so fast!
@brazilianbanker33
@brazilianbanker33 Год назад
tyty
@CodeDoge
@CodeDoge Год назад
ywyw
@ramos23vitor
@ramos23vitor Год назад
Thank you very much, in cmd the iCACLS just doesn't work, but when i used your method, it worked
@CodeDoge
@CodeDoge Год назад
glad it was helpful! Lmk if you have any future topics you want me to cover
@ramos23vitor
@ramos23vitor Год назад
@@CodeDoge for shure!
@gisele2262
@gisele2262 8 месяцев назад
Beginner user on Powershell and simply trying to delete a file with a long name. Command prompt on DOS won't work for this, so I tried Powershell. When I log into Powershell as administrator and use the "del" command with the file path for the full file name (obtained from the "dir" command), it says the file can't be found. I was able to copy the actual file path, which displayed as an abbreviated name, and when I tried deleting that, the message is that I don't have permission to perform this function. I've watched your video but it's a bit complex for me at this point. Could you go over the simplest way for me to change the permissions in Powershell, just for that file, so I can delete it? If there's a way for me to send you the screen captures of what I'm describing, please let me know. I appreciate your help and thanks.
@CodeDoge
@CodeDoge 6 месяцев назад
sorry Im 2 months too late. but I think you can try using "GCI -path {your path}" or "GCI -path {your path} -filter *{your filename}" Those should find your file and show the full path so you can use it to delete
@MrHouloul
@MrHouloul 3 года назад
If I wanna add a group of 3 users, and the group's name was Hello. So I should write $user = "Hello". Is it correct or ... ?
@CodeDoge
@CodeDoge 3 года назад
Yes, that should be fine. It should be okay to use a ServiceAccount or UserGroup in the $user variable. I have done it in the past with no issue so do let me know if theres a problem so I can try and help you out
@nuplo0522
@nuplo0522 2 года назад
how to use $folderPath = "F:\TEST Folder" $user = "Test1ng" $grant = "/grant:r" $permission = ":(OI)(CI)(M)" $inheritance = "/inheritance:e" Invoke-Expression -Command ('icacls $folderPath $inheritance $grant "${user}${permission}"') for multiple folders in a location do i add a commer after "F:\TEST Folder","F:\TEST Folder 2" or there is another way?
@CodeDoge
@CodeDoge 2 года назад
if you got multiple folder paths you should put the base code inside a loop and execute it against the list of folder paths
@alexwells2231
@alexwells2231 Год назад
Great video - how do you add container inheritance and object inheritance using the powershell version? thanks also (Get-Acl -Path $FolderPath).Access | ft and Invoke-Expression -Command ('icacls $Folderpath') are useful to see the changes
@CodeDoge
@CodeDoge Год назад
not sure what you mean for container/object inheritance in regards to this videos context.
@alexwells2231
@alexwells2231 Год назад
@@CodeDoge the equivalent of (CO)(IO) parameters used in the icacls command
@Harry-tc1im
@Harry-tc1im 3 года назад
Super helpful and thanks for the second option. When I run the code it it adds BUILTIN (BUILTIN) instead of the user, any recommendations?
@Harry-tc1im
@Harry-tc1im 3 года назад
I was using the second option as my powershell seems to be out dated
@CodeDoge
@CodeDoge 3 года назад
@@Harry-tc1im yeap I had the same issue once, was a using a onprem server that had powershell 3.x and we could not update it for whatever reason. Had to use the icacls method. Also had an issue where we were trying to create/push files to a shared drive and due to access issues, icacls.exe was the way to go again. Thanks again for watching and Im so happy I was able to help!
@CodeDoge
@CodeDoge 3 года назад
I think BUILTIN is the default user, you should be able to pass any valid user thats on your active directory. I was able to do this both at work and on my home local pc. Lmk if you get stuck Ill try to help debug!
@arlenewillems8041
@arlenewillems8041 Год назад
What is the command to apply it to the folder, subfolders and files? This is my first time doing PowerShell Script and you explained it really good. Now I have something to present to my IT Manager. Will you be able to help me with applying the full control to folder, subfolders, and files? Thanks in advance!
@CodeDoge
@CodeDoge Год назад
Depending on the method you chose, its gonna change. I personally like to use icacls so in that case use this to figure out what you need ss64.com/nt/icacls.html
@tbowen12
@tbowen12 11 месяцев назад
Same question here...
@user-cv1so5nd1t
@user-cv1so5nd1t Год назад
Hi. i want to get full access of this file "C:\Windows\System32\en-US otepad.exe.mui" but it doesnt work with the methods shown on the video. Can you help me? (please)
@CodeDoge
@CodeDoge Год назад
looks like thats a specific file. I would give access to the parent directory of that file and it should allow access to the file itself
@darshithp6383
@darshithp6383 2 года назад
Actually i am not understanding completely, need your help creating the scripts, please help me
@CodeDoge
@CodeDoge 2 года назад
hey, what part exactly? its really tough to help without any breadcrumbs on how I can help
@fwiii1831
@fwiii1831 2 года назад
Good video is it possible to restrict access to folders with command prompt and not in admin mode ?
@CodeDoge
@CodeDoge 2 года назад
you can definitely restrict access to folders by user/user group with powershell. As far as doing it in Non admin mode, I think it is unlikely. It may be possible if you have your user that you are auth as a part of user groups that can make the change, but I think its far easier to run in admin
@justinbrown8214
@justinbrown8214 11 месяцев назад
Is there a way to do this using the first method without adding a whole new access group? I simply want to modify the existing "Users" group but instead it adds a secondary Users group. Thanks for your video!
@CodeDoge
@CodeDoge 10 месяцев назад
its been some time since making this video and using this script, but you should be able to use a user directly. doesnt have to be a AD group
@justinbrown8214
@justinbrown8214 10 месяцев назад
@@CodeDogeI'm trying to change folder and registry folder permissions on client machines, eventually I'll want to push out this script to all company machines. Do you think this is the best way to achieve that? Or should I be using a batch file? Thanks again for your help.
@drin9425
@drin9425 2 года назад
How to add multiple folderpath?
@CodeDoge
@CodeDoge 2 года назад
wrap the base logic to add to a folder path and iterate through a loop, so something like, foreach ($folder in $foldersList) { } and inside {} is the logic
@rubeast
@rubeast 2 года назад
Great video, but 3 times! 3 times you want to show us the security properties of the "testFolder", but you show us the security properties of the "YT Video Folder" by right clicking without having the focus on the folder. 0:17 3:13 5:36
@CodeDoge
@CodeDoge 2 года назад
lol sorry about that. I made a mistake with the audio the first time when I was recording and I deleted the contents after the first session. I had to redo parts of the video and when I was working on the video it was like 2 am because of that. I take a lot of takes because I dont want to include my "uhs" and time wasting portions, so I record in small chunks. It was a huge ordeal to splice take 1 and take 2, I probably lost track of this during that editing. Anyways, I hope it was still helpful regardless!
@lespatriotes4101
@lespatriotes4101 2 года назад
Hello, both solutions doesn't work...why don't you type before in powershell $PSVersiontable for both solution i get an error message....
@lespatriotes4101
@lespatriotes4101 2 года назад
Set-Acl : Tentative d'exécution d'une opération non autorisée. Au caractère Ligne:9 : 8 + $acl | Set-Acl $folderPath + ~~~~~~~~~~~~~~~~~~~ + CategoryInfo : PermissionDenied: (D:\Soft_master:String) [Set-Acl], UnauthorizedAccessException + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.SetAclCommand
@lespatriotes4101
@lespatriotes4101 2 года назад
icacls : d:\Soft_master: AccŠs refus‚. Au caractère Ligne:1 : 1 + icacls $folderPath $inheritance $grant "${user}${permission}" + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (d:\Soft_master: AccŠs refus‚.:String) [], RemoteException + FullyQualifiedErrorId : NativeCommandError
@CodeDoge
@CodeDoge 2 года назад
​@@lespatriotes4101 taking a wild guess, but your error message looks like the cred executing script doesnt have access rights to set access rights. Also I did this is ps 5.1
@Thought-Hive
@Thought-Hive 2 года назад
How do I change the location?
@CodeDoge
@CodeDoge 2 года назад
you can use move-item or other tactics such as replace/rename files/locations. Video below might give an idea on the latter ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-tiouHNzAl8Q.html
Далее
Ouch.. 🤕
00:30
Просмотров 7 млн
Штаны легионера
00:44
Просмотров 151 тыс.
NTFS Explicit and Inherited Permissions
6:37
Просмотров 65 тыс.
PowerShell Access Control
53:41
Просмотров 9 тыс.
File Management with PowerShell
1:02:14
Просмотров 3,8 тыс.
PowerShell Quick Tips : Get-ACL
13:24
Просмотров 2,6 тыс.
Copy, Move, Delete files with PowerShell
17:01
Просмотров 173 тыс.
PowerShell Functions
36:06
Просмотров 42 тыс.
How To Manage NTFS Permissions With PowerShell
8:22
Просмотров 11 тыс.
Introduction to Azure ARM Templates | Powershell
1:34:19
Просмотров 1,6 тыс.
File and Folder List in PowerShell
4:35
Просмотров 6 тыс.