brianary / scripts Goto Github PK
View Code? Open in Web Editor NEWGeneral-purpose PowerShell, F#, and other scripts
License: MIT License
General-purpose PowerShell, F#, and other scripts
License: MIT License
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:
#Fields:
line would have to be parsed by powershell unless it could be piped to LogParser (does LogParser wait for EOF to output things)%
β *
and _
β ?
, with LogParser's built-in escape character \
, which isn't overridable like standard SQL)Omitting the -OutFile
param tries to transform the XML to [Console]::Out
, but that isn't working.
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
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
The script should support common secret metadata, as well as a parameter to copy the secret from the clipboard.
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.
As Select-Json.ps1 navigates its way through the provided JSON Pointer path, it may be important to follow $ref
at each step, maybe only enabled by an optional switch parameter like -FollowRefs
.
I would like to see a generic import of a server log script which can fetch and ogv server logs :)
Requested:
In PowerShell prior to 7.3, ConvertFrom-Json -AsHashtable
returns an unordered hashtable, which can change the order of properties, leading to unexpected behavior. A warning should be printed anytime that parameter is used from PowerShell earlier than 7.3.
Changing console color palettes for both default process registry settings and shortcuts are important to cover all cases. See https://github.com/lukesampson/concfg for shortcut API calls, maybe.
The call to git shortlog -nes
in Add-CodeOwners
isn't returning anything on the GitHub Actions server. Apparently a fallback is required.
An alternate parameter set that takes in-memory XML DOMs as both the XML and XSLT should be supported, or else the existing params should be more flexible.
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
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).
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.
The Use-SqlcmdParams.ps1
script should also support accepting pipeline input from dbatools' Get-DbaDatabase
and SqlServer's Get-SqlDatabase
(both return Microsoft.SqlServer.Management.Smo.Database
), so that scripts using it also support those inputs. This would require updating the comment docs' .Inputs
sections.
The script should maybe provide output similar to dbatools' Test-DbaConnection cmdlet.
Instead of using a -PathSeparator
parameter, the -PropertyName
parameter should use JSON Pointer.
This will also impact Set-VSCodeSetting.ps1.
Currently, Get-IisLog.ps1
uses a Windows-specific type only natively available in WPS. This needs to be mitigated to support PSC.
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).
Replace any uses of New-Object string $c,$n
with $c * $n
.
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)
Annee => AnnΓ©e
Since the -Path
parameter allows wildcards, the output for Resolve-JsonPointer.ps1
should include the source Path in the output (maybe this could be included or surpressed with a switch).
Support for adding/updating/choosing the schemes
in $env:LocalAppData\Microsoft\Windows Terminal\profiles.json
would be nice.
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.
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.
This should return 2
, but produces errors. JSON pointer traversal should index into arrays properly.
'{a:[1,2,3]}' |Select-Json.ps1 /a/1
This may also affect the other JSON scripts.
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.
This should allow extracting definitions from an OpenAPI/Swagger file, each into a standalone JSON Schema, with JSON References imported inline.
/schema
, /components/schemas
, /components/responses
, and /component/requestBodies
./definitions
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.