7 Replies Latest reply: Apr 29, 2013 5:34 AM by vinith RSS

remote session - save file localy

JSHACHER11
Currently Being Moderated

I am running a remote session (Enter-PSSession) and would like to save the screen output (or Out-File) locally.

 

While in a remote session, it would only save the file on the remote computer:

 

[Win5]: PS C:\> Get-NaAggr | Out-File c:\aggr.txt

 

I'm looking for a way to save the remote session locally, without actually going to the remote computer, is that possible?

 

BTW, Start-Transcript doesn't work remotely

 

Cheers

 

Joel

  • Re: remote session - save file localy
    vinith
    Currently Being Moderated

    Hello Joel.

     

    You can use the Invoke-Command cmdlet and pass the scripts inside scriptblock and put the extracted value in a variable and perform operations on them.

     

    PS C:\Windows\system32> $a = Invoke-Command -ComputerName scvmm2012sp1 -ScriptBlock { Get-WmiObject win32_computersystem }
    PS C:\Windows\system32> $a
    
    Domain              : SaRC.com
    Manufacturer        : Microsoft Corporation
    Model               : Virtual Machine
    Name                : SCVMM2012SP1
    PrimaryOwnerName    : Windows User
    TotalPhysicalMemory : 4294496256
    PSComputerName      : scvmm2012sp1
    

     

    So in Your Case, it should look like.

     

    PS C:\Windows\system32> $a = Invoke-Command -ComputerName Win5 -ScriptBlock { Get-NaAggr }
    PS C:\Windows\system32> $a | Out-File c:\aggr.txt
    
    • Re: remote session - save file localy
      JSHACHER11
      Currently Being Moderated

      Cool

       

      What if I need to run this on the remote machine and save a report locally:

       

      Import-Module DataOntap

      $filer = Read-Host "This will show volumes more than 85% full. Please enter the filer name"

      $user = "Enter the username"

      Connect-NaController $filer -Credential $user

      Get-NaVol | select name,PercentageUsed,Aggregate,SnapshotPercentReserved,SpaceReserveEnabled,MirrorStatus | where { $_.PercentageUsed -gt 85 }

More Like This

  • Retrieving data ...