locked
Powershell thru MIMWal RRS feed

  • Question

  • I upgraded from FIM to MIM and from Win2008r2 to Win2016 and found out about the Powershell v2 limitation.  I have been working on encapsulating my powershell scripts using the Run Powershell Script Activity webpage.  When I use it for calling powershell in the cloud and I get it to work and I had a script to populate msexchdeligatelistlink working up to this past fall.  Now I can not get it to work.

    param
    (
                   [parameter(mandatory = $true)] $Added,
                   [parameter(mandatory = $true)] $Removed,
                   [parameter(mandatory = $true)] $Target,
    )

    function InvokeImmediateTermination
    {
        # Any errors during execution of the script or the script block are bubbled up automatically.
        # COMMENT OUT -ComputerName parameter when running the interactively in PowerShell ISE.
    Invoke-Command -ScriptBlock {
                param($Added,$Removed,$Target)

              if (!(Get-Module -Name "ActiveDirectory"))
            {
                Import-Module ActiveDirectory
            }
          
                #Remove user in AD
                ForEach ($Removeduser in $Removed) 
                { 
                $userrdn = get-aduser -identity $Removeduser -properties *  | select Distinguishedname
                $RCNName = $userrdn.Distinguishedname
                $IDDelList = set-aduser -identity $Target -Remove @{msExchDelegateListLink= $RCNName}
                }

                #Add permissions to AD
                ForEach ($AddUser in $Added)
                {
                $userdn = get-aduser -identity $Adduser -properties * | select Distinguishedname
                $CNName = $userdn.Distinguishedname
                $IDAddList = set-aduser -identity $Target -Add @{msExchDelegateListLink= $CNName}
                }
        

      


    } -ArgumentList -ComputerName socfimport02.id.ohio.gov
      
        if ($Error)
        {
            # Communicate error back the parent workflow to abort the workflow
            throw $Error
        }

    }
    InvokeImmediateTermination

    I get no errors but it doesn't seem to work either.  In WAL event log I get the errors that it doesn't recognized powershell v3

    WAL (2.19.0112.0): 03/31/2020 16:32:52.1281: RunPowerShellScript : RunScript: PowerShell script execution resulted in 8 error(s):\nThe 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\ActiveDirectory\ActiveDirectory.psd1' module cannot be imported because its manifest contains one or more members that are not valid. The valid manifest members are ('ModuleToProcess', 'NestedModules', 'GUID', 'Author', 'CompanyName', 'Copyright', 'ModuleVersion', 'Description', 'PowerShellVersion', 'PowerShellHostName', 'PowerShellHostVersion', 'CLRVersion', 'DotNetFrameworkVersion', 'ProcessorArchitecture', 'RequiredModules', 'TypesToProcess', 'FormatsToProcess', 'ScriptsToProcess', 'PrivateData', 'RequiredAssemblies', 'ModuleList', 'FileList', 'FunctionsToExport', 'VariablesToExport', 'AliasesToExport', 'CmdletsToExport'). Remove the members that are not valid ('HelpInfoUri'), then try to import the module again.
    The specified module 'msonline' was not loaded because no valid module file was found in any module directory.
    The term 'Connect-MsolService' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    The 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\ActiveDirectory\ActiveDirectory.psd1' module cannot be imported because its manifest contains one or more members that are not valid. The valid manifest members are ('ModuleToProcess', 'NestedModules', 'GUID', 'Author', 'CompanyName', 'Copyright', 'ModuleVersion', 'Description', 'PowerShellVersion', 'PowerShellHostName', 'PowerShellHostVersion', 'CLRVersion', 'DotNetFrameworkVersion', 'ProcessorArchitecture', 'RequiredModules', 'TypesToProcess', 'FormatsToProcess', 'ScriptsToProcess', 'PrivateData', 'RequiredAssemblies', 'ModuleList', 'FileList', 'FunctionsToExport', 'VariablesToExport', 'AliasesToExport', 'CmdletsToExport'). Remove the members that are not valid ('HelpInfoUri'), then try to import the module again.
    The term 'get-aduser' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    The term 'set-aduser' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    The term 'get-aduser' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    The term 'set-aduser' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

    Extended Properties:
    WorkflowInstanceId: 294f13bf-b189-4278-b4c1-8b82d34f5c7d
    TargetId: b6bff479-a896-4401-85fa-2e03dcce10b8
    RequestId: 6d5ba406-9ff2-4204-8600-ba3d94ea9e9b
    WorkflowDefinitionId: 7b96e645-60e6-49ab-bff4-24f4ca136615
    ActorId: b6bff479-a896-4401-85fa-2e03dcce10b8

     

    Tuesday, March 31, 2020 9:00 PM

Answers

  • Have you tried running this in PowerShell ISE? Your script block expects 3 param, but the argument list to the script block is empty.
    • Marked as answer by snaber Thursday, April 2, 2020 5:29 PM
    Wednesday, April 1, 2020 9:39 PM

All replies

  • Have you tried running this in PowerShell ISE? Your script block expects 3 param, but the argument list to the script block is empty.
    • Marked as answer by snaber Thursday, April 2, 2020 5:29 PM
    Wednesday, April 1, 2020 9:39 PM
  • Ah, that is the issue, thanks.
    Wednesday, April 1, 2020 11:25 PM