PowerShell Kullanılabilir Script Örnekleri

Share

 

Süreli Ping Paket Kontrolü ve Loglama PowerShell

filter timestamp {“$(Get-Date -Format o): $_”} & ping www.google.com t | timestamp > c:\logging.txt Get-Content c:\logging.txt wait PowerShell

Stop, start ve Recycle ( Geri Dönüşüm ) Application Pools

 

AppCmd stop AppPool “example.com” AppCmd start AppPool “example.com” AppCmd start AppPool “example.com” /autoStart:true AppCmd recycle AppPool “example.com

Windows PowerShell

Durdurulan Tüm Uygulama Havuzlarını Bir Döngüde Başlatın

AppCmd list AppPools /state:stopped /xml | AppCmd start AppPool /in AppCmd list AppPools/state:stopped /xml | AppCmd start AppPool /in AppCmd list AppPools /state:stopped /autostart:true /xml | AppCmd start AppPool /in

Windows Hizmetlerini Başlatma, Durdurma ve Yeniden Başlatma

Get-Service iphlpsvc | %{ if ( $_.Status -eq “Stopped” ) { Start-Service iphlpsvc }}

Sorgulanan hizmetin durumu “Durduruldu” değerine eşitse, hizmeti başlatmak için Başlangıç Hizmeti’ni kullanın. Bunu hemen hemen her Windows hizmeti için kullanabilirsiniz, örneğin LanmanWorkstation (İş İstasyonu servisi):

Get-Service LanmanWorkstation | %{ if ( $_.Status -eq “Stopped” ) { Start-Service LanmanWorkstation }}

veya  LanmanServer (Server service):

Get-Service LanmanServer | %{ if ( $_.Status -eq “Stopped” ) { Start-Service LanmanServer }}

PowerShell’de Get-Service kullanıyorsanız, WaitForStatus yöntemini kullanarak bir hizmeti başlatmadan önce belirli bir süre bekleyebilirsiniz. Örneğin:

$service = Get-Service( ‘lanmanserver’ ) $service.stop() # stops the given service $service.WaitForStatus( ‘Stopped’, ‘0:01:00’ ) #give the service a one minute time to fully stop $service.start() # start the service

PowerShell’de Ağ Bağlantılarını Sınama

(New-Object System.Net.Sockets.TcpClient).Connect( “localhost”, “25” ) (New-Object System.Net.Sockets.TcpClient).Connect( “smtp.example.com”, “587” ) TestNetConnection Port 25 ComputerName localhost TestNetConnection Port 587 ComputerName smtp.example.com

Windows PowerShell

Toplam Okunma :%sayac_toplam%

Bugün Okunma : %sayac_bugun%

PowerShell ile IIS Add Application Convert to Application
(Visited 446 times, 1 visits today)