Start Auto Services

Automatically start Automatic services


StartAutoSvc.ps1

Description

 

Uses list of target computers. Reports on, and optionally starts, Automatic service not running.

Version

 

1.0

Last Mod

 

August 2010

Client

 

NA

Language

 

PowerShell

Finish Level

 

Smooth

Description

Script reads an input text file for a list of computers, examines each computer’s services, reports Automatic services not running and, optionally, starts them.

Configuration

Input text file lists target computers, one per line. A second input text file lists services to ignore. Path to both input files and output log file can be modified, as can the option to start the services not running. Default values:

  • Input files path: Current folder
  • Server list file: ServerList.txt
  • Excluded services list file: ExcludeList.txt
  • Log file path: Current folder
  • Log file name: StartSvcLog.txt
  • Restart Services: Yes
  • Overwrite log of same name: Yes

Usage information available with -? command line argument.

StartAutoSvc - Version 1.0, January 2011

Usage:

StartAutoSvc [ Optional Parameters ]

-InputPath <FolderWithInputFiles>

-ServerFile <ServerFileName>

-ExcludeFile <ExcludeServiceFileName>

-LogBase <BaseNameForLogFile>

-LogPath <FolderForLogFile>

-Date (include date in log filename)

-Time (include time in log filename)

-Start (start services not running - Default)

-NoStart (don't start services)

-Append (append to log)

ServerFile: List of target computers, one entry per line.

ExcludeFile: List of services to ignore, one entry per line.

LogBase: Base of log filename, optionally with date/time stamp.

LogPath: Folder for log file.

Date: switch, to include date in log filename.

Time: switch, to include time in log filename.

Start: switch, to start automatic services not running.

NoStart: switch, Do not start services not running

Append: Append to existing log file.

Not valid with [Time]

You may add a date and/or time component to the log file name with the –Date and –Time command line switches. You may append to an existing log file with the –Append command line switch, which is logically incompatible with the –Time switch. The default Start/NoStart behavior of the script can be changed by commenting/eliminating lines 584-5 within the script.

Execution

Run from anywhere. Target systems must have WMI enabled and remotely accessible. To start services, the account running script must have permissions to manipulate WMI on target systems.

Default configuration values discussed above. Modify these with command line arguments. Include parameters with their name and value separated by a space. The Date, Time, Start, NoStart, and Append arguments are switches, entered without corresponding values.

Examples:

StartAutoSvc –Date

Will include YYYYMMDD in the log file name

StartAutoSvc –Time will include HH:MM.SS.ssss

Will include a time string in the log file name.

StartAutoSvc – Append

Will append to an existing log file or create a new one if none exists.

StartAutoSvc –Append -Date

Running this command repeatedly, will create a new log for each day, with all activity for one day contained in its respective file.

 

Arguments may be entered in any order or combination except the following combinations:

      Both –Start and –NoStart

These are mutually exclusive.

      Both –Append and –Time

Since the –Time parameter will produce a unique file name, based on milliseconds, it is virtually impossible to append to an existing file of the same name.

Documentation

Just this.

Download


Up