help with the function that will work on remote computers with the icacls co

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of CloudItgirl CloudItgirl 1 day, 9 hours ago.

  • Author
    Posts
  • #58262
    Profile photo of CloudItgirl
    CloudItgirl
    Participant

    Hello,
    I am new to powershell. I am trying to write a function that will work on remote computers with the icacls command. The icacls command works find on the local computer. But I would like to process multiple computers at once.

    I am getting this error: Cannot find the type for custom attribute 'CmdletBidning'. Make sure that the assembly that contains this type is loaded.

    Can you please help

    Function Set-Permissions {
    [CmdletBidning()]
    param([Parameter(Mandatory=$true,
    ValueFromPipeline=$true,
    ValueFromPipelineByPropertyName=$true)]
    [Alias('hostname')]
    [string[]$CommputerName,
    [switch]$nameLog
    )
    BEgin {}
    Process {
    foreach ($computer in $computername)
    {
    #write-host $computer
    icacls E:\ /grant TESTTARGET\TEST.Administrators:(OI)(CI)F
    icacls F:\ /grant TESTTARGET\TEST.Administrators:(OI)(CI)F
    icacls "E:\Includes" /setowner TESTTARGET\test.svc /t /c
    icacls "E:\ADMS" /setowner TESTTARGET\test.svc /t /c
    icacls "E:\Program Files" /setowner TESTTARGET\test.svc /t /c
    icacls "F:\Software" /setowner TESTTARGET\test.svc /t /c

    }

    }

    End {}

    }

    Set-Permissions -computername .\computers
    Invoke-Command -ComputerName (Get-Content ".\Computers.txt") -ScriptBlock {Set-Permissions}

  • #58264
    Profile photo of Matt Bloomfield
    Matt Bloomfield
    Participant

    Cannot find the type for custom attribute 'CmdletBidning'

    That's a typo. It's

    [CmdletBinding()]
  • #59307
    Profile photo of CloudItgirl
    CloudItgirl
    Participant

    Thank you so much!!

You must be logged in to reply to this topic.