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
Solved

windows powershell to remote servers

Posted on 2013-06-28
5
332 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
5 Comments
 
LVL 20

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 500 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 69

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 69

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
Set OWA language and time zone in Exchange for individuals, all users or per database.
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

856 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