Change File/Folder permissions with Powershell

Поделиться
HTML-код
  • Опубликовано: 25 окт 2024

Комментарии • 55

  • @prestigequick
    @prestigequick 7 месяцев назад +1

    thank you so much i literaaly watched the first 21 seconds and got the help i needed! New Sub

    • @CodeDoge
      @CodeDoge  7 месяцев назад

      so glad it was helpful so fast!

  • @cylee604
    @cylee604 3 года назад +5

    This is SUPER helpful! #1 fan... for all your videos.......

    • @CodeDoge
      @CodeDoge  3 года назад +1

      You're the best!

  • @RonanONeill-rj9qv
    @RonanONeill-rj9qv Год назад +2

    not a programmer but I followed it and to my surprise works

    • @CodeDoge
      @CodeDoge  Год назад

      Im so happy to hear this! glad it helped!

  • @Momofoxer
    @Momofoxer 2 года назад +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 года назад +1

      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!

  • @deckpeck3002
    @deckpeck3002 3 года назад +1

    omg u really need a raise buddy. love your work ,keep it up

    • @CodeDoge
      @CodeDoge  3 года назад

      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 3 года назад

      @@CodeDoge lmao

  • @ramos23vitor
    @ramos23vitor Год назад +1

    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 11 месяцев назад +1

    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  8 месяцев назад

      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

  • @ДанаилАшков
    @ДанаилАшков Год назад

    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

  • @nuplo0522
    @nuplo0522 2 года назад +1

    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

  • @arlenewillems8041
    @arlenewillems8041 2 года назад +2

    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  2 года назад

      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 Год назад

      Same question here...

    • @andrzejmnich1285
      @andrzejmnich1285 2 месяца назад

      @arlenewillems8041 For future generations. Add /T /C at the end.
      Invoke-Expression -Command ('icacls $folderPath $inheritance $grant "${user}${permission}" /T /C')

  • @justinbrown8214
    @justinbrown8214 Год назад

    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  Год назад

      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 Год назад

      @@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.

  • @brazilianbanker33
    @brazilianbanker33 Год назад +1

    tyty

  • @darshithp6383
    @darshithp6383 3 года назад +1

    Actually i am not understanding completely, need your help creating the scripts, please help me

    • @CodeDoge
      @CodeDoge  3 года назад

      hey, what part exactly? its really tough to help without any breadcrumbs on how I can help

  • @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

  • @alexwells2231
    @alexwells2231 Год назад +1

    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 года назад +1

    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 года назад +1

      I was using the second option as my powershell seems to be out dated

    • @CodeDoge
      @CodeDoge  3 года назад +1

      @@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 года назад +1

      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!

  • @rubeast
    @rubeast 3 года назад +1

    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  3 года назад +1

      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!

  • @MrHouloul
    @MrHouloul 3 года назад +1

    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

  • @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

  • @drin9425
    @drin9425 2 года назад +1

    How to add multiple folderpath?

    • @CodeDoge
      @CodeDoge  2 года назад +1

      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

  • @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
      ruclips.net/video/tiouHNzAl8Q/видео.html