Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

Services on remote machines

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 07-02-2008   #1 (permalink)
BarbS
Guest


 

Services on remote machines

Would appreciate any help with the following script. The script reads a text
file containing a list of services that I want to change the startup type on.
For example:
alerter,disables. This works fine on the local machine. How do I read in a
list of remote machines along with the list of services.
I want to set the startup type on services of remote servers. Thanks You.

foreach ($service in get-content "V:\Program Files\PowerGUI\my
scripts\windows 2003 elective services.txt") {
$newAry = $service.split(',')
$strsvcs = $newAry[0]
$strtype = $newAry[1]
$chkservice = get-service -name $strsvcs -ErrorAction silentlycontinue
If ( ! $chkservice)
{"not installed"}
Else
{set-service $strsvcs -startuptype $strtype
"$strsvcs is $strtype"}
}


My System SpecsSystem Spec
Old 07-02-2008   #2 (permalink)
Brandon [MVP]
Guest


 

Re: Services on remote machines

get-service doesnt work remotely.. you need to use .NET or WMI. In your case
I would use WMI.

$service = get-wmiobject win32_service -computer Server1 -filter
"name='<ServiceName>'"
$service.state

"BarbS" <BarbS@xxxxxx> wrote in message
news:ECD22465-1A70-4CD6-BD01-450F14ADF27A@xxxxxx
Quote:

> Would appreciate any help with the following script. The script reads a
> text
> file containing a list of services that I want to change the startup type
> on.
> For example:
> alerter,disables. This works fine on the local machine. How do I read in a
> list of remote machines along with the list of services.
> I want to set the startup type on services of remote servers. Thanks You.
>
> foreach ($service in get-content "V:\Program Files\PowerGUI\my
> scripts\windows 2003 elective services.txt") {
> $newAry = $service.split(',')
> $strsvcs = $newAry[0]
> $strtype = $newAry[1]
> $chkservice = get-service -name $strsvcs -ErrorAction silentlycontinue
> If ( ! $chkservice)
> {"not installed"}
> Else
> {set-service $strsvcs -startuptype $strtype
> "$strsvcs is $strtype"}
> }
>
My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Remote assistance between XP and Vista machines Olumide Vista General 4 07-05-2008 07:33 AM
Remote assistance between XP and Vista machines Olumide Vista networking & sharing 1 06-17-2008 08:58 PM
Can't remote into Vista Ultimate machines eappell Vista networking & sharing 4 02-23-2008 07:23 AM
Terminal Services - Remote Desktop Connection AJD Vista General 3 11-07-2006 01:28 PM
interact with remote machines JJ Streicher-Bremer PowerShell 2 08-03-2006 04:59 AM


Update your Vista Drivers Update Your Drivers Now!!

Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008