Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

windows powershell to remote servers

Posted on 2013-06-28
5
Medium Priority
?
342 Views
Last Modified: 2013-09-06
I have one desktop PC running windows 7 + powershell.

I have a mixture of windows 2003 and 2008 servers.

I would like to write a script which logs into each one and report back the uptime of each and then export to csv file.

My question is if it is mandatory to have powershell installed on the windows 2003 or windows 2008 servers? What technology will be used by my windows 7 machine to communicate with the servers?
0
Comment
Question by:Ikky786
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 23

Expert Comment

by:Patrick Bogers
ID: 39283911
Hi,

Powershell is a nice util for this, yes it is mandatory to have it installed on your servers.
This is what the scripting guys say about server uptime.
0
 
LVL 12

Accepted Solution

by:
SreRaj earned 2000 total points
ID: 39283922
Hi,

Please try the following script. It takes input from a text file, ServerList.txt. This file should contain a server name in each line. Output will be stored in a csv file UpTimeReport.csv.

$ServerList = Get-Content ServerList.txt
$DataOutput = $Null
Set-Content UpTimeReport.csv $Null
$Header = "Server Name,Uptime"
Out-File UpTimeReport.csv -InputObject $Header -Encoding ASCII -Force
ForEach($Server in $ServerList){
    If(Test-Connection -ComputerName $Server -Count 4 -ErrorAction SilentlyContinue){
        $WMIServer = gwmi Win32_OperatingSystem -ComputerName $Server
        $LastBootTime = $WMIServer.ConvertToDateTime($WMIServer.LastBootUpTime)  
        [TimeSpan]$UpTime = New-TimeSpan $LastBootTime $(Get-Date)
        $DataOutput = '"'+$Server+'","'+"$($UpTime.Days) Days, $($UpTime.Hours) Hours and $($UpTime.Minutes) Minutes"+'"'
        Out-File UpTimeReport.csv -InputObject $DataOutput -Append -Encoding ASCII -Force
        $DataOutput
    }
    else{
        $DataOutput = '"'+$Server+'","Server not reachable"'
        Out-File UpTimeReport.csv -InputObject $DataOutput -Append -Encoding ASCII -Force
    }
}

Open in new window

0
 
LVL 71

Expert Comment

by:Qlemo
ID: 39284661
As you can see from the script, it is NOT mandatory to have PowerShell installed on the servers. But it is advisable.
Some cmdlets have remoting capabilities different from PowerShell - WMI is one example. It only requires to have the WMI services running on the target, which they do by default.

Only if you want to remote control, execute complex scripts remotely and the like you will have to have PS installed.
0
 

Author Comment

by:Ikky786
ID: 39286974
Of course it doesn't have to be wmi , I wasn't aware powershell had its own cmdlets to download and scan windows updates
0
 
LVL 71

Expert Comment

by:Qlemo
ID: 39287269
PS hasn't them build in, but one of the great features is that you can load modules at your need to extend capabilities ....
0

Featured Post

Introducing the WatchGuard 420 Access Point

WatchGuard's newest access point includes an 802.11ac Wave 2 chipset, providing the fastest speeds for VoIP, video and music streaming, and large data file transfers. Additionally, enjoy the benefits of strong security as the 3rd radio delivers dedicated WIPS protection!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question