ersin.fr
msgbartop
just my personal notebook…
msgbarbottom


27 Dec 16 Listing windows services statuses with Powershell

Advertisements
$stopingServices=Get-Service | Where-Object {$_.status -eq "stoping"}
$startingServices=Get-Service | Where-Object {$_.status -eq "starting"}
$runningServices=Get-Service | Where-Object {$_.status -eq "running"}
$stoppedServices=Get-Service | Where-Object {$_.status -eq "stopped"}


if($startingServices){
 Write-Host "`nStarting Services: $startingServices"
}
if($stopingServices){
 Write-Host "`nStoping Services: $stopingServices"
}
if($runningServices){
 Write-Host "`nRunning Services: $runningServices"
}
if($stoppedServices){
 Write-Host "`nStopped Services: $stoppedServices"
}

Tags:

23 Nov 16 view the registry entries with powershell

Get-ItemProperty -Path Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation

royal-ts-suygulama-yonetimidosyalarersinersin

Tags: ,

30 Nov 15 Installing Powershell ISE via Powershell commands

Using PowerShell

  1. Open Powershell Window
  1. Execute following cmdlets.
Import-Module ServerManager

Add-WindowsFeature PowerShell-ISE

Tags:

28 Apr 15 How to connect Oracle DB with PowerShell

# Load the ODP assembly 
[Reflection.Assembly]::LoadFile("C:\oracle\11.2.0\client_2\odp.net\bin\4\Oracle.DataAccess.dll")|Out-Null
# 
#vars&cons
$stations =@{
"424"="Istanbul";
"421"="İzmir"
}
$dbuser="user"
$dbpasswd="password"

connect to Oracle


$constr =
"
User Id=$dbuser;
Password=$dbpasswd;
Data Source=CITIES
"
$conn= New-Object Oracle.DataAccess.Client.OracleConnection($constr)
$conn.Open()

Create a datareader for a SQL statement

$sql="select stationid
from CITIES.SWITCHPARAMETER
where switchid = '2'
"
$command = New-Object Oracle.DataAccess.Client.OracleCommand( $sql,$conn)
$reader=$command.ExecuteReader()

Write out the results

# 
while ($reader.read()) {
$stationID=$reader.GetString(0)
$stationname=$stations.Get_Item($stationID)
Write-Host
"
Station ID: $stationID ($stationname)"
}

Tags: ,