PluginProbe
Code Block Pro – Beautiful Syntax Highlighting / 1.28.0
Code Block Pro – Beautiful Syntax Highlighting v1.28.0
1.27.1 1.27.2 1.27.3 1.27.4 1.27.5 1.27.6 1.27.7 1.28.0 1.3.0 1.4.0 1.5.0 1.5.1 1.5.2 1.6.0 1.7.0 1.8.0 1.9.0 1.9.1 1.9.2 1.9.3 trunk 1.1.0 1.10.0 1.11.0 1.11.1 All 63 releases
code-block-pro / build / shiki / samples / powershell.sample

powershell.sample in Code Block Pro – Beautiful Syntax Highlighting 1.28.0, at build/shiki/samples/powershell.sample

23 lines 843 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 ## Define the service name in a variable
2 $ServiceName = 'EventLog'
3
4 ## Read the service from Windows to return a service object
5 $ServiceInfo = Get-Service -Name $ServiceName
6
7 ## If the server is not running (ne)
8 if ($ServiceInfo.Status -ne 'Running') {
9 ## Write to the console that the service is not running
10 Write-Host 'Service is not started, starting service'
11 ## Start the service
12 Start-Service -Name $ServiceName
13 ## Update the $ServiceInfo object to reflect the new state
14 $ServiceInfo.Refresh()
15 ## Write to the console the Status property which indicates the state of the service
16 Write-Host $ServiceInfo.Status
17 } else { ## If the Status is anything but Running
18 ## Write to the console the service is already running
19 Write-Host 'The service is already running.'
20 }
21
22 ## From https://adamtheautomator.com/powershell-script-examples/
23