Skip to content

Instantly share code, notes, and snippets.

@101t
Last active March 2, 2021 14:09
Show Gist options
  • Save 101t/5800aaa5b435689566711db3330cc543 to your computer and use it in GitHub Desktop.
Save 101t/5800aaa5b435689566711db3330cc543 to your computer and use it in GitHub Desktop.
PowerShell Snipps Commands

PowerShell Snipps Commands

* Rename Multiple file/folder

Rename only under directory

get-childitem prefix_* | foreach { rename-item $_ $_.Name.Replace("prefix", "another_prefix") }

Rename recursivly under directory

get-childitem -path <yourpath> -recurse prefix_* | foreach { rename-item $_ $_.Name.Replace("prefix", "another_prefix") }

Windows Firewall block and restrict

New-NetFirewallRule -Name "MSSQL Block" -DisplayName "MSSQL Restrict" -Enabled True -Direction Inbound -Profile Domain, Private -Action Block -LocalPort 1433 -Protocol Any -RemoteAddress Any

restrict port to remote IP address

New-NetFirewallRule -Name "MSSQL Restrict" -DisplayName "MSSQL Restrict" -Enabled True -Direction Inbound -Profile Domain, Private -Action Allow -LocalPort 1433 -Protocol Any -RemoteAddress "IP OR Subnet goes here"

Remove *.pyc extension in directory

Get-ChildItem -Filter '*.pyc' -Force -Recurse | Remove-Item -Force

source: here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment