GithubHelp home page GithubHelp logo

brianary / scripts Goto Github PK

View Code? Open in Web Editor NEW
63.0 5.0 29.0 6.9 MB

General-purpose PowerShell, F#, and other scripts

License: MIT License

PowerShell 93.29% F# 0.32% CSS 0.31% XSLT 4.39% VBA 0.37% Batchfile 0.02% Mermaid 0.62% C# 0.69%
developer-tools powershell powershell-scripts

scripts's People

Contributors

brianary avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

scripts's Issues

Get-IisLog.ps1 should wait for new log entries if -Before is omitted

The IIS Log parsing script should allow the -Before parameter to be omitted, and watch for (and filter) new log entries.

This could use Get-Content -Wait (like tail -f on Linux) on the most recent file instead of using LogParser (which it would still do for older files), but that has some complications:

  • the #Fields: line would have to be parsed by powershell unless it could be piped to LogParser (does LogParser wait for EOF to output things)
  • the "like" operator pattern would have to be translated from LogParser SQL to PowerShell's syntax (% β†’ * and _ β†’ ?, with LogParser's built-in escape character \, which isn't overridable like standard SQL)
  • once a new file is created, watching the previous one must end, and watching the new one must begin (this one is hardest, and may require multiple threads or processes or workflows or something)

Get-EnumValues.ps1 collisions result in duplicate output

Either because the FileSystemRights Enumeration contains integer value collisions, or else because it is a Flags enumeration, Get-EnumValues.ps1 is returning duplicates.

Get-EnumValues.ps1 System.Security.AccessControl.FileSystemRights
  Value Name
  ----- ----
      1 ReadData
      1 ReadData
      2 CreateFiles
      2 CreateFiles
      4 AppendData
      4 AppendData
      8 ReadExtendedAttributes
     16 WriteExtendedAttributes
     32 ExecuteFile
     32 ExecuteFile
     64 DeleteSubdirectoriesAndFiles
    128 ReadAttributes
    256 WriteAttributes
    278 Write
  65536 Delete
 131072 ReadPermissions
 131209 Read
 131241 ReadAndExecute
 197055 Modify
 262144 ChangePermissions
 524288 TakeOwnership
1048576 Synchronize
2032127 FullControl

πŸ› Select-Json.ps1 fails to select within arrays property

This should return True, but it returns two False values:

'[{"name": true, "id": false, "description": false}]' |Select-Json.ps1 /*/name

This should return the single object within the array, but instead returns all three boolean values as if the array wasn't there:

'[{"name": true, "id": false, "description": false}]' |Select-Json.ps1 /*

For contrast, this returns True as expected:

'{"name": true, "id": false, "description": false}' |Select-Json.ps1 /name

Use-NetMailConfig.ps1 doesn't work with PowerShell Core

PowerShell Core doesn't seem to have a machine.config:

$mcfg = [Configuration.ConfigurationManager]::OpenMachineConfiguration()
$may = if(Test-Path $mcfg.FilePath){'does'}else{'does not'}
"PowerShell v$($PSVersionTable.PSVersion) uses $($mcfg.FilePath), which $may exist"

PowerShell v6.2.0 uses C:\Program Files\PowerShell\6\Config\machine.config, which does not exist

Compare to PowerShell 5.1:

PowerShell v5.1.17134.590 uses C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config, which does exist

On Windows, pwsh.exe could call powershell.exe for native access to the machine.config, but that's a pretty kludgy fix, and doesn't address other platforms.

Use-NetMailConfig.ps1 could fail on PS Core, or it could try finding .NET Framework machine.config value (either through powershell.exe or finding and parsing the config XML manually), or it could use it's own config, or some combination of these strategies.

Server log gridview script

I would like to see a generic import of a server log script which can fetch and ogv server logs :)

Requested:

  1. Ability to gather server logs VIA Alias OR Fully Qualified Domain Name and output them via grid view.

Fix Add-GitHubMetadata.Tests.ps1

The call to git shortlog -nes in Add-CodeOwners isn't returning anything on the GitHub Actions server. Apparently a fallback is required.

Get-CertificatePath.ps1 doesn't support CNG certs

Background

The new CNG provider doesn't work with the X509Certificate2 object returned by the PowerShell Certificate provider implemented by the Microsoft.PowerShell.Security module (even as late as version 6.1.1.0 in PowerShell Core v6).

PS > gi "Cert:\LocalMachine\TrustedPeople\$cngCertThumbprint" |select HasPrivateKey,PrivateKey

HasPrivateKey PrivateKey
------------- ----------
         True

PS > (gi "Cert:\LocalMachine\TrustedPeople\$cngCertThumbprint").get_PrivateKey()
Exception calling "get_PrivateKey" with "0" argument(s): "Invalid provider type specified.
"
At line:1 char:1
+ $c.get_PrivateKey()
+ ~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : CryptographicException

Ramifications

This means that accessing the private key filename is not currently, consistently, natively supported by PowerShell. Getting at that detail will require some alternative (P/Invoke of WinAPI, loading a newer system assembly, using Add-Type with some C# source, or creating a PowerShell module or NuGet package).

See also

πŸ› Use-Command.ps1 should default to global installs, or offer a switch

Currently, auto-installing npm packages with Use-Command.ps1 only installs locally, even though the intent of the script appears to be intended for machine-scoped installs. Therefore, either the npm installs should be global by default, or there should be a switch parameter that allows specifying local vs global install scope.

Get-IisLog.ps1 should support PSC

Currently, Get-IisLog.ps1 uses a Windows-specific type only natively available in WPS. This needs to be mitigated to support PSC.

✨ JSON paths should support wildcards

Currently the JSON scripts that support a -PropertyName parameter (Export-Json.ps1, Select-Json.ps1, and Set-Json.ps1) accept an RFC6901 JSON Pointer. These should add support for -like wildcards, which will mean the escapes will grow to:

  • ~0 = ~
  • ~1 = /
  • ~2 = ? (actually re-escaped as [?] for-like)
  • ~3 = * (actually [*])
  • ~4 = [ (actually [[])

This will probably result in the need for a Resolve-JsonPointer.ps1 script as well.

Also, Export-Json.ps1 should support a -Path parameter just as Select-Json.ps1 and Set-Json.ps1 (and Resolve-JsonPointer.ps1 should).

✨ Add DescriptionAttribute text to Get-EnumValues.ps1 output

In addition to the Value and Name of each enum value, returning any Description attribute content would be useful, if that is available (how common is that in the CLR?), something like this:

[ConsoleColor].GetMember('Magenta')[0].GetCustomAttributes([ComponentModel.DescriptionAttribute], $false)

Get-IisLog.ps1 should better support nonstandard methods

Right now, the $_ variable is being used, except that's the exception, not the current item.

PropertyNotFoundException: A:\bscripts\Get-IisLog.ps1:269
Line |
 269 |          catch{Write-Verbose "Nonstandard verb $($_.Method) at $($_.Fi …
     |                                                  ~~~~~~~~~
     | The property 'Method' cannot be found on this object. Verify that the property exists.

A new filter should be used to "deconstruct" and type the fields.

Get-OpenApiInfo.ps1 should include a parameter for simpler text output

Currently, Get-OpenApiInfo.ps1 returns an object, including a property that includes an array of available endpoints, which gets truncated on display. Adding a -Simple switch or -As String parameter, or an output format would provide a way to quickly see the relevant content without additional processing.

Add stylesheet to tasks XML generated by Backup-SchTasks.ps1

The Backup-SchTasks.ps1 script could add a <?xml-stylesheet href="tasks.css"?> or something similar to make that file more immediately readable, when a CSS href is given as a param. Or it could add an XSLT stylesheet for more sophistication.

Alternatively, a separate Export-ScheduledTasks.ps1 could be created that made a nice report.

Convert-OpenAPIToJsonSchema.ps1

This should allow extracting definitions from an OpenAPI/Swagger file, each into a standalone JSON Schema, with JSON References imported inline.

  • How do the different JSON Schema versions implement definitions?
    • OpenAPI 3.0/3.1 seems to use /schema, /components/schemas, /components/responses, and /component/requestBodies.
    • OpenAPI 2.0 seems to use /definitions

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.