Uploaded image for project: 'Modules'
  1. Modules
  2. MODULES-6973

Powershell exec with NetTCPIP commands fail when run as a service

    XMLWordPrintable

Details

    • Bug
    • Status: Open
    • Normal
    • Resolution: Unresolved
    • None
    • None
    • powershell
    • Normal
    • 1 - 1-5% of Customers
    • 3 - Serious
    • 4 - $$$$$
    • Hide
      Seems very weird that this doesn't work. Though we assume that most of this network config information might be available as facts. A user that has an existing powershell script that uses this command won't appreciate working around this issue though.

      Show
      Seems very weird that this doesn't work. Though we assume that most of this network config information might be available as facts. A user that has an existing powershell script that uses this command won't appreciate working around this issue though.

    Description

      When using the Powershell module with Windows and an exec, the exec is failing to load the assemblies for the NetTCPIP module.This works fine from a user session, but fails when run as LocalSystem. The Puppet service cannot run powershell scripts that have the native Get-NetIPConfiguration command in them. When running it with a user account, this is successful as well as running Get-NetIPConfiguration as the LocalSystem account manually.

      Reproduction Steps

      1. Install Windows 2012kr2
      2. Install Puppet (I am using 5.3.5)
      3. Install puppetlabs-powershell (2.1.3)
      4. From a command prompt open a local system user session.

      psexec -i -s cmd.exe
      powershell.exe
      

      5. Validate that the LocalSystem can run Get-NetIPConfiguration

      PS C:\Windows\system32> Get-NetIPConfiguration
       
       
      InterfaceAlias       : Ethernet0
      InterfaceIndex       : 12
      InterfaceDescription : vmxnet3 Ethernet Adapter
      NetProfile.Name      : Network
      IPv4Address          : 10.32.114.45
      IPv6DefaultGateway   :
      IPv4DefaultGateway   : 10.32.112.1
      DNSServer            : 10.240.0.10
                             10.240.1.10
      

      6. Run puppet apply to produce the issue

      With logoutput => true the errors are shown.

      PS C:\Windows\system32> puppet apply -e "exec{'test': provider => powershell, command => 'Get-NetIPConfiguration',  logoutput => true, }"
      Notice: Compiled catalog for iuz11jjsncyl715.delivery.puppetlabs.net in environment production in 0.15 seconds
      Notice: /Stage[main]/Main/Exec[test]/returns: New-Object : Cannot find type [NetIPConfiguration]: verify that the assembly containing this type is loaded.
      Notice: /Stage[main]/Main/Exec[test]/returns: At C:\windows\system32\windowspowershell\v1.0\Modules\NetTCPIP\NetIPConfiguration.psm1:97 char:25
      Notice: /Stage[main]/Main/Exec[test]/returns: +             $IPConfig = New-Object NetIPConfiguration
      Notice: /Stage[main]/Main/Exec[test]/returns: +                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      Notice: /Stage[main]/Main/Exec[test]/returns:     + CategoryInfo          : InvalidType: (:) [New-Object], PSArgumentException
      Notice: /Stage[main]/Main/Exec[test]/returns:     + FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand
      Notice: /Stage[main]/Main/Exec[test]/returns:
      Notice: /Stage[main]/Main/Exec[test]/returns: The property 'InterfaceIndex' cannot be found on this object. Verify that the property exists and can be set.
      Notice: /Stage[main]/Main/Exec[test]/returns: At C:\windows\system32\windowspowershell\v1.0\Modules\NetTCPIP\NetIPConfiguration.psm1:98 char:13
      Notice: /Stage[main]/Main/Exec[test]/returns: +             $IPConfig.InterfaceIndex = $IfIndex
      Notice: /Stage[main]/Main/Exec[test]/returns: +             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      Notice: /Stage[main]/Main/Exec[test]/returns:     + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
      Notice: /Stage[main]/Main/Exec[test]/returns:     + FullyQualifiedErrorId : PropertyNotFound
      Notice: /Stage[main]/Main/Exec[test]/returns:
      Notice: /Stage[main]/Main/Exec[test]/returns: The property 'NetAdapter' cannot be found on this object. Verify that the property exists and can be set.
      Notice: /Stage[main]/Main/Exec[test]/returns: At C:\windows\system32\windowspowershell\v1.0\Modules\NetTCPIP\NetIPConfiguration.psm1:103 char:13
      Notice: /Stage[main]/Main/Exec[test]/returns: +             $IPConfig.NetAdapter = $Adapters | where InterfaceIndex -eq $IfIndex
      Notice: /Stage[main]/Main/Exec[test]/returns: +             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      Notice: /Stage[main]/Main/Exec[test]/returns:     + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
      Notice: /Stage[main]/Main/Exec[test]/returns:     + FullyQualifiedErrorId : PropertyNotFound
      Notice: /Stage[main]/Main/Exec[test]/returns:
      Notice: /Stage[main]/Main/Exec[test]/returns: The property 'NetIPv4Interface' cannot be found on this object. Verify that the property exists and can be set.
      Notice: /Stage[main]/Main/Exec[test]/returns: At C:\windows\system32\windowspowershell\v1.0\Modules\NetTCPIP\NetIPConfiguration.psm1:104 char:13
      Notice: /Stage[main]/Main/Exec[test]/returns: +             $IPConfig.NetIPv4Interface = $IPInterfaces | where {($_.InterfaceInd ...
      Notice: /Stage[main]/Main/Exec[test]/returns: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      Notice: /Stage[main]/Main/Exec[test]/returns:     + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
      Notice: /Stage[main]/Main/Exec[test]/returns:     + FullyQualifiedErrorId : PropertyNotFound
      Notice: /Stage[main]/Main/Exec[test]/returns:
      Notice: /Stage[main]/Main/Exec[test]/returns: The property 'NetIPv6Interface' cannot be found on this object. Verify that the property exists and can be set.
      Notice: /Stage[main]/Main/Exec[test]/returns: At C:\windows\system32\windowspowershell\v1.0\Modules\NetTCPIP\NetIPConfiguration.psm1:105 char:13
      Notice: /Stage[main]/Main/Exec[test]/returns: +             $IPConfig.NetIPv6Interface = $IPInterfaces | where {($_.InterfaceInd ...
      Notice: /Stage[main]/Main/Exec[test]/returns: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      Notice: /Stage[main]/Main/Exec[test]/returns:     + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
      Notice: /Stage[main]/Main/Exec[test]/returns:     + FullyQualifiedErrorId : PropertyNotFound
      Notice: /Stage[main]/Main/Exec[test]/returns:
      Notice: /Stage[main]/Main/Exec[test]/returns: New-Object : Cannot find type [NetIPConfiguration]: verify that the assembly containing this type is loaded.
      Notice: /Stage[main]/Main/Exec[test]/returns: At C:\windows\system32\windowspowershell\v1.0\Modules\NetTCPIP\NetIPConfiguration.psm1:97 char:25
      Notice: /Stage[main]/Main/Exec[test]/returns: +             $IPConfig = New-Object NetIPConfiguration
      Notice: /Stage[main]/Main/Exec[test]/returns: +                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      Notice: /Stage[main]/Main/Exec[test]/returns:     + CategoryInfo          : InvalidType: (:) [New-Object], PSArgumentException
      Notice: /Stage[main]/Main/Exec[test]/returns:     + FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand
      Notice: /Stage[main]/Main/Exec[test]/returns:
      Notice: /Stage[main]/Main/Exec[test]/returns: The property 'InterfaceIndex' cannot be found on this object. Verify that the property exists and can be set.
      Notice: /Stage[main]/Main/Exec[test]/returns: At C:\windows\system32\windowspowershell\v1.0\Modules\NetTCPIP\NetIPConfiguration.psm1:98 char:13
      Notice: /Stage[main]/Main/Exec[test]/returns: +             $IPConfig.InterfaceIndex = $IfIndex
      Notice: /Stage[main]/Main/Exec[test]/returns: +             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      Notice: /Stage[main]/Main/Exec[test]/returns:     + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
      Notice: /Stage[main]/Main/Exec[test]/returns:     + FullyQualifiedErrorId : PropertyNotFound
      Notice: /Stage[main]/Main/Exec[test]/returns:
      Notice: /Stage[main]/Main/Exec[test]/returns: The property 'NetAdapter' cannot be found on this object. Verify that the property exists and can be set.
      Notice: /Stage[main]/Main/Exec[test]/returns: At C:\windows\system32\windowspowershell\v1.0\Modules\NetTCPIP\NetIPConfiguration.psm1:103 char:13
      Notice: /Stage[main]/Main/Exec[test]/returns: +             $IPConfig.NetAdapter = $Adapters | where InterfaceIndex -eq $IfIndex
      Notice: /Stage[main]/Main/Exec[test]/returns: +             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      Notice: /Stage[main]/Main/Exec[test]/returns:     + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
      Notice: /Stage[main]/Main/Exec[test]/returns:     + FullyQualifiedErrorId : PropertyNotFound
      Notice: /Stage[main]/Main/Exec[test]/returns:
      Notice: /Stage[main]/Main/Exec[test]/returns: The property 'NetIPv4Interface' cannot be found on this object. Verify that the property exists and can be set.
      Notice: /Stage[main]/Main/Exec[test]/returns: At C:\windows\system32\windowspowershell\v1.0\Modules\NetTCPIP\NetIPConfiguration.psm1:104 char:13
      Notice: /Stage[main]/Main/Exec[test]/returns: +             $IPConfig.NetIPv4Interface = $IPInterfaces | where {($_.InterfaceInd ...
      Notice: /Stage[main]/Main/Exec[test]/returns: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      Notice: /Stage[main]/Main/Exec[test]/returns:     + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
      Notice: /Stage[main]/Main/Exec[test]/returns:     + FullyQualifiedErrorId : PropertyNotFound
      Notice: /Stage[main]/Main/Exec[test]/returns:
      Notice: /Stage[main]/Main/Exec[test]/returns: The property 'NetIPv6Interface' cannot be found on this object. Verify that the property exists and can be set.
      Notice: /Stage[main]/Main/Exec[test]/returns: At C:\windows\system32\windowspowershell\v1.0\Modules\NetTCPIP\NetIPConfiguration.psm1:105 char:13
      Notice: /Stage[main]/Main/Exec[test]/returns: +             $IPConfig.NetIPv6Interface = $IPInterfaces | where {($_.InterfaceInd ...
      Notice: /Stage[main]/Main/Exec[test]/returns: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      Notice: /Stage[main]/Main/Exec[test]/returns:     + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
      Notice: /Stage[main]/Main/Exec[test]/returns:     + FullyQualifiedErrorId : PropertyNotFound
      Notice: /Stage[main]/Main/Exec[test]/returns:
      Notice: /Stage[main]/Main/Exec[test]/returns: New-Object : Cannot find type [NetIPConfiguration]: verify that the assembly containing this type is loaded.
      Notice: /Stage[main]/Main/Exec[test]/returns: At C:\windows\system32\windowspowershell\v1.0\Modules\NetTCPIP\NetIPConfiguration.psm1:97 char:25
      Notice: /Stage[main]/Main/Exec[test]/returns: +             $IPConfig = New-Object NetIPConfiguration
      Notice: /Stage[main]/Main/Exec[test]/returns: +                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      Notice: /Stage[main]/Main/Exec[test]/returns:     + CategoryInfo          : InvalidType: (:) [New-Object], PSArgumentException
      Notice: /Stage[main]/Main/Exec[test]/returns:     + FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand
      Notice: /Stage[main]/Main/Exec[test]/returns:
      Notice: /Stage[main]/Main/Exec[test]/returns: The property 'InterfaceIndex' cannot be found on this object. Verify that the property exists and can be set.
      Notice: /Stage[main]/Main/Exec[test]/returns: At C:\windows\system32\windowspowershell\v1.0\Modules\NetTCPIP\NetIPConfiguration.psm1:98 char:13
      Notice: /Stage[main]/Main/Exec[test]/returns: +             $IPConfig.InterfaceIndex = $IfIndex
      Notice: /Stage[main]/Main/Exec[test]/returns: +             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      Notice: /Stage[main]/Main/Exec[test]/returns:     + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
      Notice: /Stage[main]/Main/Exec[test]/returns:     + FullyQualifiedErrorId : PropertyNotFound
      Notice: /Stage[main]/Main/Exec[test]/returns:
      Notice: /Stage[main]/Main/Exec[test]/returns: The property 'NetAdapter' cannot be found on this object. Verify that the property exists and can be set.
      Notice: /Stage[main]/Main/Exec[test]/returns: At C:\windows\system32\windowspowershell\v1.0\Modules\NetTCPIP\NetIPConfiguration.psm1:103 char:13
      Notice: /Stage[main]/Main/Exec[test]/returns: +             $IPConfig.NetAdapter = $Adapters | where InterfaceIndex -eq $IfIndex
      Notice: /Stage[main]/Main/Exec[test]/returns: +             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      Notice: /Stage[main]/Main/Exec[test]/returns:     + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
      Notice: /Stage[main]/Main/Exec[test]/returns:     + FullyQualifiedErrorId : PropertyNotFound
      Notice: /Stage[main]/Main/Exec[test]/returns:
      Notice: /Stage[main]/Main/Exec[test]/returns: The property 'NetIPv4Interface' cannot be found on this object. Verify that the property exists and can be set.
      Notice: /Stage[main]/Main/Exec[test]/returns: At C:\windows\system32\windowspowershell\v1.0\Modules\NetTCPIP\NetIPConfiguration.psm1:104 char:13
      Notice: /Stage[main]/Main/Exec[test]/returns: +             $IPConfig.NetIPv4Interface = $IPInterfaces | where {($_.InterfaceInd ...
      Notice: /Stage[main]/Main/Exec[test]/returns: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      Notice: /Stage[main]/Main/Exec[test]/returns:     + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
      Notice: /Stage[main]/Main/Exec[test]/returns:     + FullyQualifiedErrorId : PropertyNotFound
      Notice: /Stage[main]/Main/Exec[test]/returns:
      Notice: /Stage[main]/Main/Exec[test]/returns: The property 'NetIPv6Interface' cannot be found on this object. Verify that the property exists and can be set.
      Notice: /Stage[main]/Main/Exec[test]/returns: At C:\windows\system32\windowspowershell\v1.0\Modules\NetTCPIP\NetIPConfiguration.psm1:105 char:13
      Notice: /Stage[main]/Main/Exec[test]/returns: +             $IPConfig.NetIPv6Interface = $IPInterfaces | where {($_.InterfaceInd ...
      Notice: /Stage[main]/Main/Exec[test]/returns: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      Notice: /Stage[main]/Main/Exec[test]/returns:     + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
      Notice: /Stage[main]/Main/Exec[test]/returns:     + FullyQualifiedErrorId : PropertyNotFound
      Notice: /Stage[main]/Main/Exec[test]/returns:
      Notice: /Stage[main]/Main/Exec[test]/returns: executed successfully
      Notice: Applied catalog in 3.89 seconds
      

      Workaround
      Change the service log on to another local administrator.

      Attachments

        Activity

          People

            Unassigned Unassigned
            jarret.lavallee Jarret Lavallee
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:

              Zendesk Support