Remove permissions for a security group for all files and folders in a folder and all subfolders?

I found a script that adds rights to files and folders.
We need to grant administrators rights to a set of folders for a specific project.
ChangePermissions.ps1
# CACLS rights are usually
# F = FullControl
# C = Change
# R = Readonly
# W = Write
$StartingDir=
"C:\Users"
$Principal="Administrators"
$Permission="F"
$Verify=Read-Host `n "You are about to change permissions
on all" `
"files starting at"$StartingDir.ToUpper() `n "for security"`
"principal"$Principal.ToUpper() `
"with new right of"$Permission.ToUpper()"."`n `
"Do you want to continue? [Y,N]"
if ($Verify -eq "Y") {
foreach ($file in $(Get-ChildItem $StartingDir -recurse)) {
#display filename and old permissions
write-Host -foregroundcolor Yellow $file.FullName
#uncomment if you want to see old permissions
#CACLS $file.FullName
#ADD new permission with CACLS
CACLS $file.FullName /E /P "${Principal}:${Permission}" >$NULL
#display new permissions
Write-Host -foregroundcolor Green "New Permissions"
CACLS $file.FullName
When the project is over, we need to undo the changes and remove administrators permissions from the same group of folders.
How do we change the script to remove administrators group members instead of adding?

I'm not sure I understand how to use that example script to undo the changes in the script I posted..
Is there  a way to just change a few lines in the first script so that it removes instead of adding the administrators group?
This line appears to be the line that adds permissions:
#ADD new permission with CACLS
CACLS $file.FullName /E /P "${Principal}:${Permission}" >$NULL
What would be the syntax to remove the  permissions
$Principal="Administrators"
$Permission="F"
 from files and folders in $StartingDir= "C:\Users"
and everything below it?

Similar Messages

  • SCCM 2007 database query for AD security group for machines

    dear,
    I am had created security DL in AD for machine to deploy software  and trying to link in SCCM 2007 with collection but could not
    i have tried query base following below link but its does not help
    http://www.windows-noob.com/forums/index.php?/topic/892-deploy-software-through-ad-groups-linked-to-collections-in-sccm/
    type all query but could not find in table (SystemGroupName).
    [email protected]

    Go to properties of you collection and add a new membership rule to add the security group
    SCCM use discovery methods to get information from AD. Make sure AD system discovery and AD security group discovery are enabled for the SCCM site. Once you add machines to the security group, you need to wait till the next discovery cycle is completed.
    The discovery cycle runs on a schedule set by SCCM administrator.

  • File Server Migration - For ORG A Forest to ORG B Forest ( Need to create and Map Security Group automatically on new Migrated Folders - Please Help

    I have two forest With Trust works Fine .
    I have file server in ORG – A ( Forest ) with 2003 R2 Standard
    I have a File server in ORG  - B ( Forest ) With Windows server 2012 ( New Server for Migration )
    I have 1000 + folders with each different permission sets on ORG-A. We are using Security groups for providing permission on the share Folders on ORG A
    I need to Migrate  all the folders from ORG – A to ORG – B.
    I am looking for an automated method of creating Security Groups on AD during the Migration, Once the Migration is Done, I can add the required users to the security groups manually.
    Example.
    Folder 1 on ORG – A has Security Group Called SEC-FOLDER1-ORGA
    I need an automated method of Copying the files to ORG – B and Creating a new security Groups on ORG –B Forest with the same permission on parent and child Folders. I shall Add the users manually to the Group.
    Output Looks Like
    Folder 1 on ORG – B has Permission called SEC-FOLDER1-ORGB ( New Security Group )
    Also I need a summarized report of security Group Mapping, Example – Which security Group on ORGA is mapped with Security Group Of ORGB

    Hi,
    I think you can try ADMT to migrate your user group to target domain/forest first. Once user groups are migrated, you can use Robocopy to copy files with permission - that permission will continue be recognized in new domain as you migrated already. 
    Migrate Universal Groups
    http://technet.microsoft.com/en-us/library/cc974367(v=ws.10).aspx
    If you have any feedback on our support, please send to [email protected]

  • How can we provide access/provide permissions to a user/group for group of folders at single step??

    Hi Nico, Thaks you so much for your reply,, Can you please advice or give me some steps to write script pelase? Regards,Kareem

    Hi All, How can we provide access/provide permissions to a user/group for group of folders  at single step?? I can able to provide access for a single folder at a time. I want provide access to a list of  folders( more than 30 ..) at single step?? Regards,Kareem

  • Security Groups for the alerts in SharePoint 2013?

    By default Microsoft has blocked to add Security Groups for the alerts in SharePoint 2013. It can be enabled but need to change the SharePoint System page setting with the help
    of below link:
    http://thesharepointfarm.com/2013/10/setting-sharepoint-alerts-on-active-directory-security-groups/
    So my query is if I change the page setting then in future if any SharePoint updates/ hotfixes deploy in system so will it cause a problem??

    I would wait as this is not a supported workaround (although it does work).
    Trevor Seward
    Follow or contact me at...
    &nbsp&nbsp
    This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.

  • Error : Wage Type is not allowed for personnel SG grouping for WT 3

    Hi All,
    When i am trying to create wage type Degree allowance i am getting error like below.
    WT xxxx is not allowed for personnel SG grouping for WT 3 (from 01.09.2006 to
    31.12.9999)
         Message no. PG 074
    Diagnosis
         In the "Personnel Subgroup Grouping for Primary Wage Types" view
         (V_001P_K), the employee is assigned to personnel SG for primary wage
         types 3. However, this grouping is not valid for wage type xxxx in the
         period from 01.09.2006 to 31.12.9999.
    Please let me know where i needs to check.
    Thanks.

    try to change the start date and try like 01.01.1990 like this
    juss chk and update

  • Adding responsibility objects for the Notification Groups for a PA

    Hi Gurus,
    I am supposed to add responsibility objects for the notiifcation groups for a PA.. Could you please confirm the steps I am planning to follow
    1. Find out the Workflow
    2. Add the responsibilities objects ( Where can Add  those ( in the workflow or in Org Management?)
    3. Edit the rule to point to that PA..
    I am new to workflows ..points are assured for the help

    Just write your own composite Icon class:
    public class CompositeIcon implements Icon
      private Icon icon1;
      private Icon icon2;
      public CompositeIcon(Icon icon1, Icon icon2)
        this.icon1 = icon1;
        this.icon2 = icon2;
      public int getIconHeight()
        return Math.max(icon1.getIconHeight(), icon2.getIconHeight());
      public int getIconWidth()
        return icon1.getIconWidth() + icon2.getIconWidth();
      public void paintIcon(Component c, Graphics g, int x, int y)
        icon1.paintIcon(c, g, x, y);
        icon2.paintIcon(c, g, x + icon1.getIconWidth, y);
    }Hopefully a slightly more reusable solution. You could write all sorts of different layouts in this way.
    Hope this helps.

  • Will there be a patch for the security flaw for iMac version 10.6.8.?

    Will ther be a patch for the security flaw for iMac version 10.6.8?

    What security flaw are you referring to? If you're referring to the recent SSL flaw, that was only present in OS X 10.9.
    Regards.

  • HT5312 Hi, i'm forget answer for may security questions for Apple ID and can't reset it

    HI. i'm forget answer for may security questions for Apple ID and can't reset it, after verified email adress the link for reset questions is not available.

    The reset link will only show if you have a rescue email address on your account - if you've just added an address then it will be an alternate/secondary email address, which is a different setting/address on your account (a rescue email address can only be added by answering 2 of your questions).
    You will need to contact iTunes Support / Apple to get the questions reset : http://support.apple.com/kb/HT5699
    When they've been reset you can then use the steps half-way down the page that you posted from to add a rescue email address for potential future use

  • HT1911 I am Forget answers for the security questions for my Apple ID

    I am Forget answers for the security questions for my Apple ID

    See Kappy's previous write-up.
      Some Solutions for Resetting Forgotten Security Questions: Apple Support Communities

  • How to move all files to the top level folder?

    I want to move all files within a particular folder -- and all files in all sub folders -- to the top level. i.e. I want to collapse the folder structure to just one folder. Assume that there are no files with the same name.
    *Method 1*
    My first thought was to use Find:
    1. Limit Find to the particular folder.
    2. Find all files in the folder with Size > 0.
    3. Switch to List view. All files are listed.
    4. Select all files and drag to the top folder
    5. Delete all sub folders manually.
    Problem: Pages files are not found, and maybe others aren't.
    This is a simple method and I'd like to stick with it.
    *QUES 1*
    What condition should I set within Find so that I can be guaranteed of finding all files?
    *Method 2*
    It was suggested in another thread that I use Terminal to move all files to the top level, but I couldn't get it to work. And there was a problem with files that consist of bundles.
    *QUES 2*
    What is the easiest way to consolidate all files within a folder to the top level -- assume no duplicate names -- and at the same time remove all sub folders?
    Message was edited by: Guy Burns

    Thanks for the suggestion of EasyFind.
    To find all files in a certain folder I typed in *[a-z 0-9] as a Boolean search (this thread won't let me post the exact characters required by EasyFind). That should cover every file I've ever named. EasyFind came back with "11719found/12316done".
    Any idea what the missing 500 files would be? I'm hoping they are files that I don't need to know about (invisible files, system files and so on).
    Message was edited by: Guy Burns

  • Can any one tell me how can I move to a different folder pictures, that I've cloned, without them staying aggregated? They all come together to the other folder and I don't want that- thanks

    Can any one tell me how can I move to a different folder pictures, that I've cloned, without them staying aggregated? They all come together to the other folder and I don't want that… thanks

    There's more to it than that.
    Folders in Aperture do not hold Images.  They hold Projects and Albums.  You cannot put an Image in a Folder without putting it in a Project or an Album inside that Folder.
    The relationship between Projects and Images is special:  every Image must in a Project, and can be in only one Project.
    Images can be in as many Albums you want.  Putting an Image in an Album does not move it from the Project that holds it.
    You can make as many Versions from a Master as you want.
    What you want to do may appear simple to you, but it still much adhere to how Aperture works.  I still can't tell exactly what you are trying to do (specifically: Images don't live in Folders; moving an Image from a Folder is non-sensical).
    It can be very confusing (and frustrating) to get going with Aperture -- but it does work, and can be enormously helpful.  If you haven't, take a look at the video tutorials on Apple's Aperture support site.
    I feel as though I haven't helped you much -- but we need to be using the same names for interface items in order to get anything done -- and my sense is that you still haven't learned the names of the parts.

  • Aim to process all files in folders on desktop to run through photoshop and save in multiple locations

    Aim to process all files in folders on desktop to run through photoshop and save in multiple locations
    Part one:-
    Gather information from desktop to get brand names and week numbers from the folders
    Excluding folders on desktop beginning with "2" or "Hot"
    Not sure about the list of folders
    but I have got this bit to work with
    set folderPath to "Hal 9000:Users:matthew:Desktop:DIVA_WK30_PSD" --<<this would be gained from the items on the desktop
    set {oldTID, my text item delimiters} to {my text item delimiters, ":"}
    set folderName to last text item of folderPath
    set my text item delimiters to "_WK"
    set FolderEndName to last text item of folderName
    set brandName to first text item of folderName
    set my text item delimiters to "_PSD"
    set weekNumber to first text item of FolderEndName
    set my text item delimiters to oldTID
    After running this I have enough information to create folders in multiple locations, (i need to know where they are so that photoshop can later save them in those multiple locations
    So I need the following folders created
    Locally
    Hal 9000:Users:matthew:Pictures:2011-2012:"WK" + weekNumber
    Hal 9000:Users:matthew:Pictures:2011-2012:"WK" + weekNumber: brandName
    Hal 9000:Users:matthew:Pictures:2011-2012:"WK" + weekNumber: brandName: brandName + "_WK" + weekNumber + "_LR" --(Set path for Later)PathA
    Hal 9000:Users:matthew:Pictures:2011-2012:"WK" + weekNumber: brandName: brandName + "_WK" + weekNumber + "_HR"--(Set path for Later)PathB
    Network
    Volumes:GEN:Brands:Zoom:Brands - Zoom:Upload Photos:2012:"Week" + weekNumber
    Volumes:GEN:Brands:Zoom:Brands - Zoom:Upload Photos:2012:"Week" + weekNumber:brandName + "_WK" + weekNumber + "_LR"  --(Set path for Later)PathC
    Volumes:GEN:Website_Images --(no need to create folder just set path)PathD
    FTP (Still as a normal Volume) So like another Network
    Volumes:impulse:"Week" + weekNumber
    Volumes:impulse:"Week" + weekNumber:Brand
    Volumes:impulse:"Week" + weekNumber:Brand:brandName + "_WK" + weekNumber + "_LR"  --(Set path for Later)PathE
    Volumes:impulse:"Week" + weekNumber:Brand:brandName + "_WK" + weekNumber + "_HR"  --(Set path for Later)PathF
    I like to think that is end of Part 1
    Part 2
    Take the images  (PSD's) from those folders relevant to the Brand then possibly run more applescript that opens flattens and then saves it in the locations above.
    For example….
    An image in folder DIVA_WK30_PSD will then run an applescript in Photoshop, lets call it DivaProcessImages within this we then save to PathA, PathB, PathC, PathD, PathE, PathF the folder path of C should therefore look like this
    Volumes:GEN:Brands:Zoom:Brands - Zoom:Upload Photos:2012:Week30:DIVA_WK30_LR and of course save the image as original filename.
    Then from the next folder
    An image in folder Free_WK30_PSD will then run an applescript in Photoshop, lets call it FreeProcessImages within this we then save to PathA, PathB, PathC, PathD, PathE, PathF the folder path of C should therefore look like this
    Volumes:GEN:Brands:Zoom:Brands - Zoom:Upload Photos:2012:Week30:Free_WK30_LR and of course save the image as original filename.
    The photoshop applescript i'm hoping will be easier as it should be a clearer step by step process without any if's and but's
    Now for the coffee!!

    Hi,
    MattJayC wrote:
    Now to the other part, where each folder was created (and those that already existed) how do I set them as varibles?
    For example,
    set localBrandFolder_High_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_HR", localBrandFolder)
    This line was used to create more than one folder as it ran though the folders on the desktop. The next part is I will need to reference them to save files to them.
    You can use a records
    Examples
    if you want the path of localBrandFolder_High_Res  of "Diva", if "Diva" is the second folder of the Desktop
    You get the path with this : localBrandFolder_High_Res of record 2 of myRecords
    if you want the path of localWeekFolder  in the first folder of the Desktop
    You get the path with this : localWeekFolder of record 1 of myRecords
    Here is the script
    set myRecords to {}
    set dtF to paragraphs of (do shell script "ls -F ~/Desktop | grep '/' | cut -d'/' -f1")
    repeat with i from 1 to number of items in dtF
        set this_item to item i of dtF
        if this_item does not start with "2_" and this_item does not start with "Hot" then
            try
                set folderPath to this_item
                set {oldTID, my text item delimiters} to {my text item delimiters, ":"}
                set folderName to last text item of folderPath
                set my text item delimiters to "_WK"
                set FolderEndName to last text item of folderName
                set brandName to first text item of folderName
                set my text item delimiters to "_PSD"
                set weekNumber to first text item of FolderEndName
                set my text item delimiters to oldTID
            end try
            try
                set this_local_folder to "Hal 9000:Users:matthew:Pictures:2011-2012"
                set var1 to my getFolderPath("WK" & weekNumber, this_local_folder)
                set var2 to my getFolderPath(brandName, var1)
                set var3 to my getFolderPath(brandName & "_WK" & weekNumber & "_LR", var2)
                set var4 to my getFolderPath(brandName & "_WK" & weekNumber & "_HR", var2)
                --set up names to destination folders and create over Netwrok including an already exisiting folder
                set this_Network_folder to "DCKGEN:Brands:Zoom:Brand - Zoom:Upload Photos:2012:"
                set var5 to my getFolderPath("WK" & weekNumber, this_Network_folder)
                set var6 to my getFolderPath(brandName, var5)
                set var7 to my getFolderPath(brandName & "_WK" & weekNumber & "_LR", var6)
                set website_images to "DCKGEN:Website_Images:"
                --set up names to destination folders and create over Netwrok for FTP collection (based on a mounted drive)
                set this_ftp_folder to "Impulse:"
                set var8 to my getFolderPath("Week" & weekNumber, this_ftp_folder)
                set var9 to my getFolderPath(brandName, var8)
                set var10 to my getFolderPath(brandName & "_WK" & weekNumber & "_LR", var9)
                set var11 to my getFolderPath(brandName & "_WK" & weekNumber & "_HR", var9)
                set end of myRecords to ¬
      {localWeekFolder:var1, localBrandFolder:var2, localBrandFolder_Low_Res:var3, localBrandFolder_High_Res:var4, networkWeekFolder:var5, networkBrandFolder:var6, networkBrandFolder_Low_Res:var7, ftpWeekFolder:var8, ftpBrandFolder:var9, ftpBrandFolder_Low_Res:var10, ftpBrandFolder_High_Res:var11}
            end try
        end if
    end repeat
    localBrandFolder_High_Res of record 2 of myRecords -- get full path of localBrandFolder_High_Res in the second folder of Desktop
    on getFolderPath(tName, folderPath)
        tell application "Finder" to tell folder folderPath
            if not (exists folder tName) then
                return (make new folder at it with properties {name:tName}) as string
            else
                return (folder tName) as string
            end if
        end tell
    end getFolderPath

  • Ust purchase an iphone 4s and need to know how could i transfer all files including (contacts, pictures, music, notes and ect.... from sd card or any external card to iphone 4s, please advise thx

    ust purchase an iphone 4s and need to know how could i transfer all files including (contacts, pictures, music, notes and ect.... from sd card or any external card to iphone 4s, please advise thx.

    You need to put all of your info on your computer and then sync it to iphone.

  • Use AD Security Groups for SharePoint database permissions

    In our SharePoint environment we have around 30 content databases. Each of these content databases need a few application pool accounts added to there permissions for various service applications etc. Currently all the accounts are added individually,
    but this can be a little error prone. Is there a reason why we could just pop all the required accounts in an AD security group and add that database permissions in SQL?

    You could do that, but your service accounts shouldn't be accessing the databases directly, instead routing through the SharePoint API, which then permissions would be taken care of by SharePoint accounts (or if you have custom Service Applications, the
    service app pool account).
    Trevor Seward
    Follow or contact me at...
    &nbsp&nbsp
    This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.

Maybe you are looking for

  • HT1918 How do I remove a credit card from my apple account?

    I am trying to remove my credit card from my account because I have a gift card and it is not letting me remove it? Can someone please help me.

  • Calling a stored procedure with the DI API in 6.5

    Hi, Is it possible to do this? I have the following lines of code...     sSQL = "EXEC sp_AgedDebtForCustomerStatement"     oRecordset.DoQuery sSQL This procedure runs fine in SQL Query Analyzer and the query generator in B1. When I use it in my VB ap

  • How do I add a third party plugin in main stage

    Hi, I have the latest version of mainstage and I just downloaded Lounge Lizards Rhodes sounds. It has a stand alone application, but I want to use those sounds in mainstage... How the heck can I do this? I've looked everywhere, and it's not recognise

  • [SOLVED] Flashplugin Does Not Work With Firefox.

    Hi, all. Happy to have just installed Arch, after not using it for a while. It's looking as good as ever, but I can't get Flash to work. I installed Gnash and some things work, but not many. Wanting to be able to use a full Flash implementation, I in

  • Error in TransferRules Activation

    Hi all I got this error when im activating TransRules in dev box… Actually I hav copied the cube struc from parent cube and add 4 keyfig additionally we using flatfile as SourceSys Can anyone tell me wat could be the reason and how can I solve this i