Q: invoke-command get-counter ... possible?

This topic contains 5 replies, has 2 voices, and was last updated by Profile photo of CTX_Christian CTX_Christian 2 years, 3 months ago.

  • Author
    Posts
  • #18076
    Profile photo of CTX_Christian
    CTX_Christian
    Participant

    Hi again,

    using the get-counter cmdlet to gather data from machines seems somewhat cumbersome.

    I tryied to use the invoke-command cmdlet in combination with get-counter to have the remote machines do the job.

    The question is now: How can I aggragate the data the remote machines produce.

    When using get-counter without invoke-command I can add an export-counter cmdlet which writes all data in one nice .blg file. With invoke-command I did not get this to work.

    regards

    Christian

  • #18174
    Profile photo of Don Jones
    Don Jones
    Keymaster

    Can you provide a small example of what isn't working?

  • #18180
    Profile photo of CTX_Christian
    CTX_Christian
    Participant

    Hi Don,

    this is what I'm trying to execute:

    invoke-command -ComputerName REMOTECOMPUTER {get-counter -counter "\logicaldisk(_total)\Disk Transfers/Sec" -SampleInterval 3 -Continuous| Export-counter -force -Path \\MYCOMPUTER\temp\myoutput.blg}

    I get an Error:

    Unable to create the \\MYCOMPUTER\temp\myoutput.blg file. Verify that the path is valid.
    + CategoryInfo : InvalidResult: (:) [Export-Counter], Exception
    + FullyQualifiedErrorId : FileCreateFailed,Microsoft.PowerShell.Commands.ExportCounterCommand
    + PSComputerName : REMOTECOMPUTER

    I checked for permissions. I can access the share \\MYCOMPUTER\temp from another server box when logged in to Windows without having to authenticate explicit.

    share permission is set to "Everyone" R/W
    Security is set to "Everyone" Full control

    I tested with test-path and resolve-path as well from a remote box:

    PS C:\Users\myuserpath> resolve-path \\MYCOMPUTER\temp

    Path
    —-
    Microsoft.PowerShell.Core\FileSystem::\\MYCOMPUTER\temp

    PS C:\Users\myuserpath> test-path \\MYCOMPUTER\temp
    True

    Did I miss something here?

    regards

    Christian

  • #18181
    Profile photo of CTX_Christian
    CTX_Christian
    Participant

    ...I just PS remoted to the REMOTECOMPUTER from my box. When I test it from there I get the following:

    PS C:\Windows\system32> Enter-PSSession REMOTECOMPUTER
    [REMOTECOMPUTER]: PS C:\Users\myuserpath\Documents> test-path \\MYCOMPUTER\temp
    test-path : Access is denied
    + CategoryInfo : PermissionDenied: (\\MYCOMPUTER\temp:String) [Test-Path], UnauthorizedAccessException
    + FullyQualifiedErrorId : ItemExistsUnauthorizedAccessError,Microsoft.PowerShell.Commands.TestPathCommand

    False
    [REMOTECOMPUTER]: PS C:\Users\myuserpath\Documents> resolve-path \\MYCOMPUTER\temp
    resolve-path : Access is denied
    + CategoryInfo : PermissionDenied: (\\MYCOMPUTER\temp:String) [Resolve-Path], UnauthorizedAccessException
    + FullyQualifiedErrorId : ItemExistsUnauthorizedAccessError,Microsoft.PowerShell.Commands.ResolvePathCommand

    resolve-path : Cannot find path '\\MYCOMPUTER\temp' because it does not exist.
    + CategoryInfo : ObjectNotFound: (\\MYCOMPUTER\temp:String) [Resolve-Path], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.ResolvePathCommand

    Test-path and resolve-path from a Windows Server 2008 R2 box to my Windows 7 share works.
    Test-path and resolve-path from a Windows 7 box to my own Windows 7 share does not work.

    Same user account is beeing used. Same domain.

    regards

    Christian

  • #18193
    Profile photo of Don Jones
    Don Jones
    Keymaster

    The problem is most likely authentication. By default, the computer you've remoted to cannot use your credential to access non-local resources like a UNC. This is referred to as the "second hop" problem, and is discussed in "Secrets of PowerShell Remoting," one of our free ebooks (Resources menu here on the site).

  • #18232
    Profile photo of CTX_Christian
    CTX_Christian
    Participant

    Already reading it... thanks Don.

You must be logged in to reply to this topic.