Advertisement
TDiff

Use Cmdlets Without Naming Them

Mar 15th, 2019
372
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Powershell functions used to execute cmdlets without explicitly naming them
  2. # Author : TDiff
  3. # Example of usage (using New-Object without naming it by its name) :
  4. # .(q "1B-60-00-93-3C-FE-59-C5-5C-71-4D-C9-97-1E-5F-B8-69-E9-04-3A") -COM Wscript.Shell
  5. # Usage of w function :
  6. # w "Cmdlet-Name"
  7.  
  8. # Functions :
  9. # Get the cmdlet searching names matching a hash
  10. function q($h){gcm|?{[System.BitConverter]::ToString((New-Object System.Security.Cryptography.SHA1CryptoServiceProvider).ComputeHash([system.Text.Encoding]::UTF8.GetBytes($_.name)))-eq$h}}
  11.  
  12. # Get the hash of a cmdlet's name
  13. function w($h){[System.BitConverter]::ToString((New-Object System.Security.Cryptography.SHA1CryptoServiceProvider).ComputeHash([system.Text.Encoding]::UTF8.GetBytes($h)))}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement