- Open PowerShell as Administrator
Test-WSMan xx.xxx.xxx.xxEnable-PSRemoting- Enter public IP address of nano server:
$ip = "xx.xxx.xxx.xx"
Set-Item WSMan:\localhost\Client\TrustedHosts "$ip" -Force Enter-PSSession -ComputerName $ip -Credential "~\Administrator"
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
| Function Show-ModExplore { | |
| <# | |
| .SYNOPSIS | |
| Generate all the exploration I normally do when I want to install a new PowerShell module | |
| .DESCRIPTION | |
| Script to generate all the exploration I normally do when I want to install a new PowerShell module |
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
| CREATE DATABASE [٠০౦০٠]; | |
| GO | |
| USE [٠০౦০٠]; | |
| GO | |
| CREATE SCHEMA [٠০౦০٠]; | |
| GO | |
| CREATE TABLE [٠০౦০٠].[٠০౦০٠]([٠০౦০٠] NVARCHAR(20), [۰০౦০٠] NVARCHAR(20), [٠০౦০۰] NVARCHAR(20), [۰০౦০۰] NVARCHAR(20)); | |
| GO | |
| CREATE UNIQUE CLUSTERED INDEX [٠০౦০٠] ON [٠০౦০٠].[٠০౦০٠]([٠০౦০٠], [۰০౦০٠], [٠০౦০۰], [۰০౦০۰]); | |
| GO |
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
| Function New-Something {} | |
| Function Test-ShouldProcess { | |
| [CmdletBinding(SupportsShouldProcess, ConfirmImpact='Medium')] | |
| Param( | |
| [Parameter()] | |
| [switch] | |
| $Force | |
| ) |
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
| # Resets the password for the default LXSS / WSL bash user, based on https://askubuntu.com/a/808425/697555 | |
| $lxssUsername = (Get-ItemProperty HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss).DefaultUsername | |
| lxrun /setdefaultuser root | |
| bash -c "passwd $lxssUsername" | |
| lxrun /setdefaultuser $lxssUsername |
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
| { | |
| "version": "0.1.0", | |
| "tasks": [ | |
| { | |
| "taskName": "build", | |
| "command": "powershell", | |
| "args": ["Merge-Script -Script '${file}' -Bundle -OutputPath '${fileDirname}\\out' -OutputType Executable"], | |
| "isBuildCommand": true, | |
| "showOutput": "silent" | |
| } |
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
| # all logging settins are here on top | |
| $logFile = "log-$(gc env:computername).log" | |
| $logLevel = "DEBUG" # ("DEBUG","INFO","WARN","ERROR","FATAL") | |
| $logSize = 1mb # 30kb | |
| $logCount = 10 | |
| # end of settings | |
| function Write-Log-Line ($line) { | |
| Add-Content $logFile -Value $Line | |
| Write-Host $Line |
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
| param($AccountName) | |
| # Reset a pwd, requires reset pwd rights on the obj: | |
| Set-AdAccountPassword -Identity $AccountName -Reset -NewPassword (Read-Host -asSecureString "Enter the new password") | |
| # Change a pwd, knowing the current password | |
| Set-AdAccountPassword -Identity $AccountName -OldPassword (Read-Host -asSecureString "Enter the current password") -NewPassword (Read-Host -asSecureString "Enter the new password") |
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
| # | |
| # Originally from: "http://sbrickey.com/Tech/Blog/Post/Parsing_IIS_Logs_with_PowerShell" | |
| # | |
| # Define the location of log files and a temporary file | |
| $LogFolder = "C:\inetpub\logs\LogFiles\W3SVC123" | |
| $LogFiles = [System.IO.Directory]::GetFiles($LogFolder, "*.log") | |
| $LogTemp = "C:\inetpub\logs\LogFiles\W3SVC123\AllLogs.tmp" | |
| # Logs will store each line of the log files in an array |
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
| function Get-DiskFree | |
| { | |
| [CmdletBinding()] | |
| param | |
| ( | |
| [Parameter(Position=0, | |
| ValueFromPipeline=$true, | |
| ValueFromPipelineByPropertyName=$true)] | |
| [Alias('hostname')] | |
| [Alias('cn')] |
NewerOlder