Powershell - gpawade/gpawade.github.io GitHub Wiki
$ Get-Command # Return all command list
$ Get-Command *site* # Return all command contain word site
$ Get-ChildItem Env: # Display List of environment variable
$ Test-Path # Determines whether path exist
$ Invoke-RestMethod # Send an http request to a RESTFUL web service
$Env:VariableName # Return the enviroment variable value
$_ # Current pipeline object
$Args # Argument to script function
https://docs.microsoft.com/en-us/powershell/module/webadminstration/?view=winserver2012-ps
Import-Module WebAdministration
New-Website -Name mypoc.com -HostHeader mypoc.com -PhysicalPath D:\Site\mysite.com
New-WebApplication -Site "Default Web Site" -Name MusicWorld -PhysicalPath c:\inetpub\wwwroot\MusicWorld -Force
New-WebAppPool -Name MyPOC.com -Force
get-website | where-object { $_.name -eq 'MyWebsite1' }
if($(Get-Website | Where-Object { $_.name -eq "mysite" }) -eq $null ){ Write-Host "Not Exist" }
Test-Path "IIS:\AppPool\appppol_name"
Set-ItemProperty "IIS:\AppPools\MyPOC.com" -name "processModel" -Value @{ idleTimeout="00:40:00"}
Set-ItemProperty "IIS:\AppPools\MyAppPool" -name "failure" -Value @{
orphanWorkerProcess="True"; # Or False
orphanActionExe="C:\MyorphanScript.exe";
orphanActionParams="-Parameter 'orphan'";
loadBalancerCapabilities="TcpLevel"; # HttpLevel
rapidFailProtection="False"; # Or True
rapidFailProtectionInterval="00.00:07:00";
rapidFailProtectionMaxCrashes=10;
autoShutdownExe="C:\MyShutdownExe.exe";
autoShutdownParams="-parameter 'ShutdownExe'";
}
Creating funciton in file
function Get-MyResult{
param($a, $b)
Write-Host "param are $a and $b
}
. c:\myfunc.ps1
Get-MyResult -a 12 -b 324