Last active
January 4, 2018 13:17
-
-
Save masterkawaster/02015cd7c06859931f2e71db6ac854fe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#get sql cmd | |
Install-module -Name SqlServer -Scope CurrentUser -Repository <repository> | |
# Import the SQL Server Module. | |
Import-Module Sqlps -DisableNameChecking; | |
# To check whether the module is installed. | |
Get-Module -ListAvailable -Name Sqlps; | |
cd SQLSERVER:\SQL | |
#List of functions in powershell module: | |
Import-Module -Name <ModuleName> | |
Get-Command -Module <ModuleName> | |
#Find module in repository | |
Find-Module -Filter Cookbook -Repository PSGallery | |
#to run ps1 from powershell script: | |
Invoke-Expression "c:\my scripts\test script.ps1" | |
iex "c:\my scripts\test script.ps1" | |
& "c:\my scripts\test script.ps1" | |
"c:\my scripts\test script.ps1" | |
#refresh env variables in shell: | |
refreshenv | |
#restart iis | |
iisreset /restart | |
#.net framework versions | |
Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -recurse | Get-ItemProperty -name Version,Release -EA 0 | Where { $_.PSChildName -match '^(?!S)\p{L}'} | Select PSChildName, Version, Release | |
#extract zip | |
Expand-Archive .\yourfile.zip -DestinationPath c:\dest | |
#show files content | |
type filename | |
gc filename | |
#restart iis | |
net stop w3svc | |
net start w3svc | |
#or | |
iisreset -restart | |
#list env variables: | |
#all | |
Get-ChildItem Env: | |
#specifiv: | |
Get-ChildItem Env:Env_Var_Name | |
#list process names with ports | |
netstat -b | |
#show app pool properties: | |
Import-Module WebAdministration | |
Get-ItemProperty IIS:\AppPools\DefaultAppPool | select * | |
#set managed framework of iis app pool to none: | |
Set-ItemProperty -Path IIS:\AppPools\DefaultAppPool -Name managedRuntimeVersion "" | |
#web request | |
Invoke-WebRequest | |
#Get sid from the user name: | |
$objSID = New-Object System.Security.Principal.SecurityIdentifier ` | |
("S-1-5-21-1454471165-1004335555-1606985555-5555") | |
$objUser = $objSID.Translate( [System.Security.Principal.NTAccount]) | |
$objUser.Value | |
#and name from sid: | |
$objUser = New-Object System.Security.Principal.NTAccount("fabrikam", "kenmyer") | |
$strSID = $objUser.Translate([System.Security.Principal.SecurityIdentifier]) | |
$strSID.Value | |
#show members of administrators group | |
net localgroup Administrators |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment