Author Posts

August 18, 2014 at 1:26 am

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

August 20, 2014 at 2:38 am

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

August 20, 2014 at 4:05 am

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

August 20, 2014 at 4:12 am

...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

August 20, 2014 at 7:57 am

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).

August 21, 2014 at 5:30 am

Already reading it... thanks Don.