Spectra Assure
Community
  • Toolbox
  • Explore
  • Learn
  • ReversingLabs
  • Spectra Assure
    Community
    passEverything is awesome!
    Scanned: 6 days ago

    ExtendFunction

    latest
    Apteco PS Modules - PowerShell functions extension This function helps to gather all parameters that a function/cmdlet has except the common parameters like -verbose etc. This can be used to extend existing functions/cmdlets with more scripting and possibly additional parameters. So in this example you see how it works ```PowerShell # These functions inherit the parameters of the original functions/cmdlets # And as an example adds an additional parameter # There are two functions for the different PowerShell Editions function Invoke-DesktopWebRequest { [CmdletBinding()] param ( [Parameter(Mandatory=$true)][String]$AdditionalString ) DynamicParam { Get-BaseParameters "Invoke-WebRequest" } Process { Write-Host "Using `$PSEdition: Desktop" Write-Host $AdditionalString $updatedParameters = Skip-UnallowedBaseParameters -Base "Invoke-WebRequest" -Parameters $PSBoundParameters Invoke-WebRequest @updatedParameters } } function Invoke-CoreWebRequest { [CmdletBinding()] param ( [Parameter(Mandatory=$true)][String]$AdditionalString ) DynamicParam { Get-BaseParameters "Invoke-WebRequest" } Process { Write-Host "Using `$PSEdition: Core" Write-Host $AdditionalString $updatedParameters = Skip-UnallowedBaseParameters -Base "Invoke-WebRequest" -Parameters $PSBoundParameters Invoke-WebRequest @updatedParameters } } ``` And this can be used like ```PowerShell #----------------------------------------------- # CREATE AN ALIAS DEPENDING ON $PSEdition #----------------------------------------------- # In this example differentiates between Core and Desktop, but creates one alias for different $PSEdition # Just type $PSEdition if you want to know which edition you are using Switch ( $PSEdition ) { "Desktop" { Set-Alias -Name Invoke-WebRequestExtended -Value Invoke-DesktopWebRequest -Force } "Core" { Set-Alias -Name Invoke-WebRequestExtended -Value Invoke-CoreWebRequest -Force } } #----------------------------------------------- # EXAMPLE TO LOAD DATA WITH THE NEW ALIAS #----------------------------------------------- $myParams = [Hashtable]@{ Uri = "https://api.chucknorris.io/jokes/random" Method = "Get" Verbose = $true AdditionalString = "Hello World" } $wr = Invoke-WebRequestExtended @myParams ( $wr.content | ConvertFrom-Json ).Value ```
    License: unknown
    Published: 9 months ago

    SAFE Assessment

    Compliance

    Licenses
    No license compliance issues
    Secrets
    No sensitive information found

    Security

    Vulnerabilities
    No known vulnerabilities detected
    Hardening
    No application hardening issues

    Threats

    Tampering
    No evidence of software tampering
    Malware
    No evidence of malware inclusion

    This website uses cookies to ensure the best website experience. By continuing to use this website you are giving your consent to cookies being used. Detailed information about our use of cookies is here.