none
A parameter cannot be found that matches parameter name 'InformationAction' RRS feed

  • Question

  • I'm trying to remotely rename a list of PCs in parallel but I keep getting the error "Microsoft.PowerShell.Utility\Write-Error : A parameter cannot be found that matches parameter name 'InformationAction'" in the Rename function. I've only been working with powershell for a couple of days so I am still not sure what Im doing wrong here. Below is my code minus the Verify function, which is long and has bed formating when pasted into the code block. It seems to work fine as far as I can tell however
    function main{
        $DomainCredential = Verify
        $computers = GetComputers
        Rename -computers $computers -DomainCredential $DomainCredential
    }
    function GetComputers{
        $userinput = Read-Host "Enter the PC numbers to be named. Do not include 'PC' only type the following numbers. Type 'end' when finished"
        $oldnames = New-Object System.Collections.ArrayList
        while($userinput -ne "end"){
            $userinput = "$('PC')$($userinput)"
            [void]$oldnames.Add($userinput)
            $userinput = Read-Host
        }
        return $oldnames
    workflow Rename{
        Param 
        ($computers, 
        $DomainCredential)
        foreach -parallel ($computer in $computers){
            $newname = "$($computer)$('MK')"
            Rename-Computer -InformationAction Ignore -PSComputerName $computer -NewName $newname -DomainCredential $DomainCredential
        }
    }
    
    main
    

    Tuesday, November 19, 2019 7:46 PM

All replies

  • Are all the machines running the same version of Powershell (presumably 5.1)?

    This may explain it: https://gist.github.com/kusuriya/d193ffa1f4df5d04560ebbf930f99f75


    --- Rich Matheisen MCSE&I, Exchange Ex-MVP (16 years)

    Tuesday, November 19, 2019 8:03 PM
  • The error is quite explicit. There is no such parameter for that CmdLet. Just remove it.

    I also recommend defining the workflow outside of the function.


    \_(ツ)_/

    Tuesday, November 19, 2019 8:05 PM
    Moderator
  • Hi,
    Was your issue resolved? 
    If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.
    If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.
    If no, please reply and tell us the current situation in order to provide further help.
    Best Regards,
    Lee

    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Monday, November 25, 2019 9:57 AM
    Moderator