xtodo PowerShell
- PowerShell find out how to calculate a duration. startime, endtime, unix seconds, minus, turn secs to minute second
- modify my backup file to do it.
- add to my tutorial
- in powershell, how to write a command that can take a piped input or without
- https://x.com/i/grok/share/KblDbnwo1V4YplVJ1EofLqy9D
- write a powershell function, that has one paramater, can take pipedline input.
- if called by itself without pipe, list files names ending in jpg in current dir.
- if got piped input, filter files ending jpg.
- faaking powershell complexity.
- how to write a command that accept a pipe but can also run by itself.
- very faaking extremely confusing.
- even ai bot can't do it correctly.
- https://x.com/xah_lee/status/1960366153957581013
for coders. advanced PowerShell complexity.
- if you want to write a function that takes a pipe, easy, just add the process block e.g.
- process {something $_ }
- if you want it to take a param, easy, just have the begin block e.g.
- begin {something $myparam or foreach $myparam }
- but if you want the command to accept pipe if piped, like most PowerShell commands, it is faakin confusing.
- ai bots gets it wrong.
- seems, you have to introduce a local variable...
- also, there is no easy way to determine if the function is piped.
- how to do it?
function xx { [CmdletBinding()] param ( [Parameter(ValueFromPipeline = $true)] [object]$InputObject ) process { Write-Host "input is", $input } } Get-ChildItem | xx
- 2025-05-07 PowerShell make sure pwsh xah-move-files-to-xgpc do remove metadata on jpg and png. test with move from mac
PowerShell how to connect to a private network drive
New-PSDrive -Name Z -PSProvider FileSystem -Root "//xpc/users/xah/Pictures/"
# 2025-03-09 <# in PowerShell, how to get "File and Printer Sharing" status The Get-NetFirewallProfile cmdlet displays the currently configured options for a specified profile. This cmdlet displays information that is presented on the Windows Firewall with Advanced Security Properties page, with the tabs for Domain, Private, and Public profiles. The specified profile can be scoped to input rules. #> Get-NetFirewallProfile -PolicyStore ActiveStore # HHHH------------------------------ Get-NetFirewallProfile -Name Public # big output Get-NetFirewallProfile -Name Public | Get-NetFirewallRule # HHHH------------------------------ Get-NetFirewallProfile -Name private # big output Get-NetFirewallProfile -Name private | Get-NetFirewallRule
<# 2025-03-09 Get-NetFirewallRule Retrieves firewall rules from the target computer. The Get-NetFirewallRule cmdlet returns the instances of firewall rules that match the search parameters from the user. See the New-NetFirewallRule cmdlet for more information. This cmdlet returns one or more firewall rules by specifying the Name parameter (default), the DisplayName parameter, rule properties, or by associated filters or objects. The queried rules can be placed into variables and piped to other cmdlets for further modifications or monitoring. #> Get-NetFirewallRule -PolicyStore ActiveStore # HHHH------------------------------ Get-NetFirewallProfile -Name Public | Get-NetFirewallRule # HHHH------------------------------ $nfServiceFilter = Get-NetFirewallRule -Group "@FirewallAPI.dll,-30502" | Get-NetFirewallServiceFilter -Service Any Set-NetFirewallServiceFilter -Service Ssdpsrv -InputObject $nfServiceFilter This cmdlet can be run using only the pipeline. Get-NetFirewallRule -Group "@FirewallAPI.dll,-30502" | Get-NetFirewallServiceFilter -Service Any | Set-NetFirewallServiceFilter -Service Ssdpsrv
- write a PowerShell command to move files from a dir list into new dir.
- 2024-01-06 write a PowerShell command copy mirror a dir structure.
- 2022-04-16 PowerShell, write script to find huge files
- 2022-04-16 PowerShell, write script to check folder size, disk usage analysis
- 2024-03-18 PowerShell, write a command to delete Thumbs.db, and also other mac trash files
- 2021-12-26 PowerShell write xah-report-file-name-length.
- 2021-11-17 PowerShell write xah-replace-string. look at my golang python ones
- PowerShell
xah-line-ending-report
,xah-line-ending-to-unix
need complete overhaul. confusing.
- need to use
Set-ItemProperty
- PowerShell: List All Possible File Attribute Values
- 2022-06-23 PowerShell PowerShell: Eject Disk
- 2022-03-28 PowerShell
dir "c:/Users/xah//git/xahemacs/" -Force -Recurse | Where { $_.Attributes -match "ReparsePoint"}
- 2022-03-06 PowerShell. write a function to change links, relative path to domain. on file.
- move_wordyenglish_com_replace_url.ps1