Modifying script to not prompt for information - Please Help

Hello,
Wondering if any one can help me with this?
We just had one of our techs leave and he had come up with a PS script to check for specific Windows services and have them emailed daily so that we were alerted of any that are stopped.
It works perfectly except for the fact it prompts you to enter an 'Environment' for which you want to check this for. We would like to change it so that it doesn't prompt and just reports on the services for those servers listed and have it running as a scheduled
task.
See a copy of the script below.
Your assistance would greatly be appreciated.
#### Define Parameters
param (
[Parameter(Mandatory=$true, helpmessage="Which environment?")]
[validateset("Dummy","Prod")]
[string]$Environment)
#### Define variables
$HtmlFile="E:\temp\ServiceStatus.html"
#### Start Functions ####
Function Email
Send-MailMessage -SmtpServer emailserver.com -To [email protected] -From [email protected] -Subject Win-Services -Body ($Subject | Out-String) -BodyAsHtml -Priority High -UseSsl
Function Check-Services {
# Set server names based on environment selected
$Servers = switch ($Environment)
Prod {@('SERVER1','SERVER2')}
Dummy {@('SERVER3')}
# Check servers for active services
Foreach ($Server in $Servers)
try
$Services = switch ($Server)
#Prod servers
SERVER1 {@('Specific Service')}
SERVER2 {@('Specific Service','Another Service')}
#Dummy servers
SERVER3 {@('Specific Service','Another Specific Service')}
Foreach ($Service in $Services)
$global:ServiceStatus = @($ServiceStatus) + @(Get-Service -ComputerName $Server -Name $Service)
catch [Exception]
$global:ServiceExecption = $_.Exception.Message
finally
Out-Null
#### End Functions ####
# Check application services are running on all servers
Check-Services $Environment
# Build report
$Style = @"
<style>
TABLE {border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}
TH {border-width: 1px;padding: 3px;border-style: solid;border-color: black;background-color: #6495ED;}
TD {border-width: 1px;padding: 3px;border-style: solid;border-color: black;}
</style>
$b = "<H2> Application Services</H2>"
$PostContent = "<i>Report generated by Service Technical automation</i>"
$ServiceStatusHTML = $ServiceStatus | Select MachineName,DisplayName,Status | ConvertTo-Html -Body $b
$Body = ($ServiceStatusHTML)
ConvertTo-Html -Title "Service Daily Report" -Head $Style -Body $Body -PostContent $PostContent | Out-File $HtmlFile
# Set Email body content
$Subject = Get-Content $HtmlFile
# Send Report
Email $Subject
Clear-Variable ServiceStatus -Scope Global

Like this?
#### Define variables
$HtmlFile="E:\temp\ServiceStatus.html"
#### Start Functions ####
Function Email
Send-MailMessage -SmtpServer emailserver.com -To [email protected] -From [email protected] -Subject Win-Services -Body ($Subject | Out-String) -BodyAsHtml -Priority High -UseSsl
Function Check-Services {
# Set server names based on environment selected
$Servers = @('SERVER1','SERVER2')
# Check servers for active services
Foreach ($Server in $Servers)
try
$Services = switch ($Server)
#Prod servers
SERVER1 {@('Specific Service')}
SERVER2 {@('Specific Service','Another Service')}
Foreach ($Service in $Services)
$global:ServiceStatus = @($ServiceStatus) + @(Get-Service -ComputerName $Server -Name $Service)
catch [Exception]
$global:ServiceExecption = $_.Exception.Message
finally
Out-Null
#### End Functions ####
# Check application services are running on all servers
Check-Services
# Build report
$Style = @"
<style>
TABLE {border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}
TH {border-width: 1px;padding: 3px;border-style: solid;border-color: black;background-color: #6495ED;}
TD {border-width: 1px;padding: 3px;border-style: solid;border-color: black;}
</style>
$b = "<H2> Application Services</H2>"
$PostContent = "<i>Report generated by Service Technical automation</i>"
$ServiceStatusHTML = $ServiceStatus | Select MachineName,DisplayName,Status | ConvertTo-Html -Body $b
$Body = ($ServiceStatusHTML)
ConvertTo-Html -Title "Service Daily Report" -Head $Style -Body $Body -PostContent $PostContent | Out-File $HtmlFile
# Set Email body content
$Subject = Get-Content $HtmlFile
# Send Report
Email $Subject
Clear-Variable ServiceStatus -Scope Global

Similar Messages

  • Sound not working for dv6700 PLEASE HELP!!!!

    I'm having sound problems on my hp dv6700.  The sound was working last night and this morning, now when I went on it all of a sudden the sound stopped working.  When I plug in a set of headphones it works but the speakers don't work.  If someone could please help me out, I rather not have to take it to Best Buy and pay to have them fix it.

    I am experiencing the same problem, same laptop. I did try reinstalling the Conexant Audio driver but it gave me a failure message "Could Not Find Media Device for the Drive" so looking forward to suggestions.

  • I got a replacment iphone 4 but it will not work for me please help??

    i got a replacment iphone 4 but it will not work for me it has been charging for nearly 4 hours now but the screen still has the battery in the red and also will not connect to itunes is there something im doing wrong??

    You'll have to get it serviced or replaced again, contact Apple, usually a replaced device is under warranty for 90 days as well.
    Apple - Support - Service Answer Center

  • This one is for Nancy o contact form does not work for me. please help

    http://alpenawebdesigns.com/form1.html
    for css i have form1.css and for php i have vsi2.php
    when i submit the form i get a 404 error and requested url/form-to-email.php not  found
    i like the form and for the life in me i can not see the obvious
    thank you
    allen macfalda

    I changed the vsi2.php to form-to-email.php and it appears to work exceppt that it does not send a return email
    allen macfalda

  • FaceTime is not working for me please help

    I updated my new iPod5 and my FaceTime logged out of its self some how and when I type in my ID and password it's say check my internet there is a problem with it and it is perfectly fine on everything else I don't know what to do I bees to FaceTime people and now I can't please help

    http://support.apple.com/kb/ts4268

  • Adcfgclone.pl dbTier is not prompting for ORACLE_HOME variable

    hi,
    adcfgclone.pl is not prompting for ORACLE_HOME variable.
    and erroring out with
    Checking the port pool 12
    done: Port Pool 12 is free
    Report file located at /appsutil/out/portpool.lst
    RC-00203: Unable to create/write to file /appsutil/out/portpool.lst.
    Complete port information available at /appsutil/out/portpool.lst
    RC-50004: Error occurred in CloneContext:
    AC-00005: No write permissions for creating the Context file - /appsutil/temp.xml
    Raised by oracle.apps.ad.context.AppsContext
    Check Clone Context logfile /mnt/ebs/PTCH/bin/db/tech_st/12.1.0/appsutil/clone/bin/CloneContext_0421032159.log for details.
    ERROR: Context creation not completed successfully.
    For additional details review the file /tmp/adcfgclone_6999.err if present.
    DOC refrred: How To Quick Solve This Post Clone Error : RC-50004, AC-00005: No Write Permissions For Creating The Context file - /tmp/temp.xml ? (Doc ID 842948.1)
    in the above DOC please let me know how to perform ANALYSIS part..
    Database version: 12.1.0.2.0
    Applications version: 12.1.3
    OS                         : OEL6.4
    please suggest
    Thanks
    Raghavendra

    are you able to create a file with os user which is running the rapidclone in /appsutil/temp.xml
    please check and update
    use touch command to create a file
    did you gave correct oracle home when prompted by rapidclone ?
    If you have set the right permissions at /tmp and the problem remains then check if at the post cloning steps at the dbTier, the scripts asks for the "Oracle Database Home"
    Target System RDBMS ORACLE_HOME Directory [/u01/clone/db/11.2.0/] :
    post the output of below command
    $ls -ltr ( in appsutil folder )
    AppsMasti
    sharing is Caring

  • Send to OneNote from Outlook does not prompt for location

    Hello
    Since the most recent update, the Send To OneNote feature in Outlook does not prompt for a location but seems to be defaulting to the same notebook each time - even if it is not the active notebook. I've tried repairing Office 365 but it did not work. Is
    this a known issue?
    Thank you
    Simon

    Hi,
    Just checking in to see if the information was helpful. Please let us know if you would like further assistance. 
    Best Regards,
    Steve Fan
    Forum Support
    Come back and mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback on our support, please click
    here

  • Not prompting for the parameters of stored procedures while running

    Hi All,
    I have a stored proc which takes in 3 parameters and execute a copy of a record in a table based on the 3 parameters which I pass in.
    When I use the proc in crystal reports (Crystal Reports 2008), it is not prompting for the parameter values if we execute the report directly. It's prompting the values only when I do 'Veriyf Database' from the menu. Why is it not prompting for values when executing directly. Am I missing anything here?
    Also, I have a C# .net project which uses the report and take in input parameters. Even there, previously, I used to call the VerifyDatabase () first and then the SetParameterValues () which was working fine for regular expressions. But for this report (which uses stored procedure), it is not giving the desired output (copying data), even though the report doesn't fail to run. But when I changed the order of the call to have SetParameterValues () before the call to VerifyDatabase (), it works fine (copies the data for the given input parameters).
    Please let me know what is missing here? Is the order of the call to VerifyDatabase () and SetParameterValues () matters? If so, why is it working for regular expressions and not for stored procs?
    Please clarify.
    Thanks,
    Siva.

    I recommend posting this to the Crystal Reports Design forum. As I read it:
    When I use the proc in crystal reports (Crystal Reports 2008), it is not prompting for the parameter values if we execute
    the report directly. It's prompting the values only when I do 'Verify Database' from the menu. Why is it not prompting
    for values when executing directly. Am I missing anything here?
    The issue is in the CR designer 1st. So it needs to be resolved there before moving on to the CR SDK in .NET.
    Link to CR design forum:
    SAP Crystal Reports, version for Visual Studio
    Ludek

  • That did not help me find out needy iPhone will break Icloud account for Iphone his serial number (DN**********TTN) for I am I can not activate buy user please help

    That did not help me find out needy iPhone will break Icloud account for Iphone his serial number (DN******TTN) for I am I can not activate buy user please help
    <Personal Information Edited by Host>

    Your question isn't at all clear. Is this a second-hand phone which has been locked by the previous user?  In that case only the previous owner can unlock it, either by providing you with the account ID and password, or by removing it from his list of devices (as he should have done before selling it) - please see http://support.apple.com/kb/ts4515
    If you unable to contact him to do this then I'm afraid you will not be able to use the device - there is no other way of unlocking it at all.
    You should if possible return it to wherever you bought it and ask for a refund as in this event the device is completely useless.
    You should not post serial numbers or any other personal data here; I've asked the Hosts to remove it.

  • Infoview not prompting for parameters

    Hi all,
    quite basic question but I have spent hours on this now so decided to ask.
    I have a Crystal report based on BW query which has date range as mandatory variable.
    How do I control whether the Crystal report promts for that variable or not when opening. When I open the Crystal Report from INfoview it does not prompt for this parameter, although it did so previously.
    Is the setting with the paramter in the CR or with report options?
    thanks

    Hi,
    can you please check if the option Save data with the report is selected? You will find this under the File menu in the CR designer. If the option is selected then the report will not try to fetch data from the database when opened and therefore will not prompt you for the date variable. In this case you will have to refresh the report explicitely in the InfoView
    Regards,
    Stratos

  • When i open iphoto i see my photo's for 1 second and then they are gone .The photo's are still there but i can see them only on the bottom or top of my screen when i try to open them i get a sign that it is not possible.Can somebody please  help me?

    when i open iphoto i see my photo's for 1 second and then they are gone .The photo's are still there but i can see them only on the bottom or top of my screen when i try to open them i get a sign that it is not possible.Can somebody please  help me?

    Have you upgraded to iPhoto 9.6 for compatibility with Yosemite? If not, try that first.
    It looks like iPhoto has lost the connection between the thumbnails and the original image files.
    This can be caused by a corrupted iPhoto library, or the originals have been deleted or moved.
    Try first to rebuild your iPhoto Library:
    If you do not have a current backup of the iPhoto library, make a copy of the library, but do not overwrite any previous backup.
    Launch iPhoto with the ⌥⌘-key combination (option-command) held down.
    Select "rebuild" from the first aid panel.  This may take a while for a large library.
    Can you now see your photos again?
    If not, rebuild the library with iPhoto Library manager as described by Old Toad:            Re: iphoto crashed

  • I have updated my ipod touch to ios5 and it is saying that the device is not registered in apple developers program.I have a back up fle in itunes and itunes is not prompting for restore.how can i restore my pod?pls help me to restore my ipod .am worried

    I have updated my ipod touch to ios5 and it is saying that the device is not registered in apple developers program.I have a back up fle in itunes and itunes is not prompting for restore.how can i restore my pod?pls help me to restore my ipod .am worried as it my new ipod and am not able to restore it.pls help.

    i have done that .:(..PLs help me restoring it to older version.though i have a back up file.in itunes..am not able to restore it.as itunes is not asking for resotre option..pls help me

  • HT201270 i have just updated my old 3GS and now when i am on restore the window is comming up and asking for a password. i have not set up a password for restore, please help how i can restore my date???

    i have just updated my old 3GS and now when i am on restore the window is comming up and asking for a password. i have not set up a password for restore, please help how i can restore my date???

    capriz wrote:
    i have just updated my old 3GS ...
    To what... iOS 7 is Not supported on the 3 GS

  • I have created a form which needs to be completed once a week for 6 weeks. On completing week 1, weeks 2 - 6 are completed at the same time with week 1 information. please help?

    I have created a form which needs to be completed once a week for 6 weeks. On completing week 1, weeks 2 - 6 are completed at the same time with week 1 information. please help?

    Hello, thanks for replying.
    Yes they just copy to the next page, the fields are the same. The document is an observation to school lessons so it needs to be consistent but with different data on.

  • My Bluetooth has disappeared and I have tried just about everything on the internet. When I click on Bluetooth file exchange it says hardware not found. I tried resetting everything as well nothing is working for me please help because now my facetim

    My Bluetooth has disappeared and I have tried just about everything on the internet. When I click on Bluetooth file exchange it says hardware not found. I tried resetting everything as well nothing is working for me please help because now my facetime doesn’t work neither does photo booth and now I cannot text people off my laptop unless they have iMessage.

    If you followed the instructions in the support article exactly (leaving the machine off for two minutes), then it has a hardware fault. Take it to an Apple Store or other authorized service provider for repair.

Maybe you are looking for

  • Basic Auth with WebView

    Hello everyone, we have integrated some JavaFX components within a swing application recently. One of the components that we have decided to add is a WebView component that should access an html page with the account settings of the logged in user. H

  • Create a class

    I have been having problems with creating a class with actionscript project in flashbuilder. Here is a simple class but how do I use this with the skeleton code here? How do I arrange these files to make this work? Here I instatiate the class var p1

  • I recently downloaded PS CC 2014 and want to sync my settings including plugins... How do I handle the plugins...reinstall?

    Is there an easy way to sync plugins without reinstalling?  I was hoping that PS2014 would just be an upgrade, but it downloaded a whole new program to my drive. 

  • BSP Checkbox Application.

    Dear All, I am facing an issue. I had developed an application using BSP - HTML with ABAP.In this application, i have two pages.I am calling 2nd page from 1st page based on some input on first page.Based on input on first page,second page is displayi

  • Product User Profile

    I want to restrict my users to access my database using SQLPLUS or any other third party tool. I have used Product User Profile to restrict users from using DML commands through SQLPLUS. Product User Profile doesn't work with any third party tool. Is