#!/usr/bin/env pwsh function FuncCheckService
{
$ServiceName = 'pgsql-9.2'
$arrService = Get-Service -Name $ServiceName
if ($arrService.Status -eq 'Running')
{
Write-Output "$ServiceName service is running"
}
else
{
Write-Output "$ServiceName service is not running"
}
}
#start transscript to log details
Start-Transcript -Path "C:\Users\sup_jelborough\Documents\CheckPostgresService.log" -Append -IncludeInvocationHeader
#Call function with EM service as a parameter
FuncCheckService pgsql-9.2
#stop logging
Stop-Transcript
produces:
Code:
> ./s1
Start-Transcript : Transcription cannot be started due to the error: Cannot
find drive. A drive with the name 'C' does not exist.
At line:20 char:2
+ Start-Transcript -Path "C:\Users\sup_jelborough\Documents\CheckPostg ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Start-Transcript], PSInva
lidOperationException
+ FullyQualifiedErrorId : CannotStartTranscription,Microsoft.PowerShell.Co
mmands.StartTranscriptCommand
Get-Service : The term 'Get-Service' is not recognized as the name of a
cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the
path is correct and try again.
At line:7 char:16
+ $arrService = Get-Service -Name $ServiceName
+ ~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-Service:String) [], Command
NotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
pgsql-9.2 service is not running
Stop-Transcript : An error occurred stopping transcription: The host is not
currently transcribing.
At line:26 char:2
+ Stop-Transcript
+ ~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Stop-Transcript], PSInval
idOperationException
+ FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.S
topTranscriptCommand
Not surprising because I don't have your environment. The Get-service issue might be a problem.
Hi
I am new in unix. oracle and unix are installed in my sytem.i need the script
which could connect to the oracle using username ,password and schema and can run the select * from tab query.
Thanks
vijay (8 Replies)
Hi all,
I am beginner in UNIX...I want to use unix shell script to create text.file...I know how to use using by command...can anybody tell me for the script?
Thanks
i changed the threads title from "tex file" to "text file", because "tex" would probably be misunderstood as reference to... (4 Replies)
Dear all, I am very new to UNIX but and need some help in order to make BO DI Job Server execute a .sh script.
My unix script has set permissions as under:
-rwxrwxrwx.
What I m trying to do is move a .txt file from one directory to another on UNIX server. I have full access to Feed... (7 Replies)
Can anyone help me with a dos batch script to execute a shell script residing in an unix server. I am not able to use ssh.
Thanks in advance (2 Replies)
Need some help getting this script to work. can someone help. I am trying to create a script that moves log files to another location and only keeps 60 days worth. please see script I started but having issue getting to work..
$TODAY=GET-DATE
GET-CHILDITEM C:\test\*.LOG | Where {... (9 Replies)
Hi team,
My requirement is to transfer pdf files from windows machine to unix server and then from that unix server we should sftp to another server.
I have completed the first part i.e From windows to using to unix server with the help of psftp.exe
code:
psftp user@host -pw password <... (1 Reply)
Hello Friend,
I am not expert in power shell scripting. I nee custom powershell script which check if given process is running on windows machine or not.
will use it in nagios to monitor that process. (0 Replies)
Hello Experts,
I am creating a run time powershell script on Linux machine and copying that powershell script to Windows machine. To connect to windows through "ssh", I am using Cygwin tool. To make the connection password less I copied my public in authorized_keys in windows Administrator... (5 Replies)
Here is a powershell script to use restful API to create ticket in our ticketing tool. Can anyone please convert it to a shell script sothat, I can run it in Unix servers,
below is the code:
$body = @{
Customer= ''test'
Summary= 'test summary'
Impact= '4-Minor/Localized'
... (2 Replies)