Get IP address, subnet, gateway and DNS server of the NICs using PowerShell
Refs:PowerShell/IP/Address/gateway/DNS
PS C:\prj> Get-Alias -Definition Remove-Item CommandType Name Version Source ----------- ---- ------- ------ Alias del -> Remove-Item Alias erase -> Remove-Item Alias rd -> Remove-Item Alias ri -> Remove-Item Alias rm -> Remove-Item Alias rmdir -> Remove-Item
PS C:\> Remove-Item -Recurse -Force .\folder_to_delete\
PS C:\> rm -r -fo .\folder_to_delete\
PS C:\>winget install Microsoft.PowerShell
PS C:\>Get-ItemProperty 'HKCU:\Control Panel\International\Geo\' | select -exp Name
While loop
while ($true) { |
Append to file
New-TimeSpan -Start @(Get-Process explorer)[0].StartTime | Out-File -Append -FilePath C:\tmp\log.txt |
Keywords: PowerShell Quick Tips
REF:003
PS C:\>Set-DisplayResolution -Width 1600 -Height 900
PS C:\>New-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters -Name DisabledComponents -Value 0xFF -PropertyType DWord
PS C:\>Get-Item HKLM:SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters
PowerShell Quick Tips: In Linux/Unix, touching a file means to create, change or modify the timestamp of a file. Windows via cmd.exe nor PowerShell.exe does not have this tool by default. To create a file do the following in PowerShell
PS C:\> echo $null > filename.txt
PS C:\> New-EventLog -LogName 8thstring -Source 8thSource
PS C:\> Write-EventLog -LogName 8thstring -Source 8thSource -Message "Hello world" -EventId 0 -EntryType information
PS c:\> Set-DnsClientServerAddress -InterfaceIndex 10 -serveraddresses ("192.168.137.1")
PS c:\> Get-NetAdapter | where {$_.Name -eq "Ethernet 3"} | Format-List *
PS c:\> Invoke-Expression C:\Users\User01\Documents\script1.ps1
PS c:\> Get-WmiObject Win32_Service -Filter "startname like '_NetBiosName_%'" | Format-Table name, startname, startmode
I have been using Github gists to share code and I have no plan of abandoning it. For smaller/one liners, I sometimes use div element with ...