Programming + ScriptingPowershell Misc Snippets Updated August 11 2024
### Text to Speech
$Path = "$env:temp\file.wav"
Add-Type -AssemblyName System.Speech
$synthesizer = New-Object -TypeName System.Speech.Synthesis.SpeechSynthesizer
$synthesizer.SetOutputToWaveFile($Path)
$synthesizer.Speak('This is a recording.')
$synthesizer.Speak('Adding more to it')
$synthesizer.SetOutputToDefaultAudioDevice()
# Play back the recorded file
Invoke-Item $Path



### View properties of an object
Get-Process *note* | ConvertTo-Json | Out-File $env:APPDATA\GM.json ; $IE=new-object -com internetexplorer.application ; $IE.navigate2("http://jsonviewer.stack.hu/") ; $IE.visible=$true ; notepad "$env:APPDATA\GM.json"



### Find files modified recently
(Get-ChildItem -Path c:\pstbak\*.* -Filter *.pst | ? {
$_.LastWriteTime -gt (Get-Date).AddDays(-3)
}).Count



### See complete Powershell command history, for all time
notepad (Get-PSReadLineOption).HistorySavePath



### See Powershell command history, for current session
CTRL-R, CTRL-Space, F8, or Get-History




©2024 - Some portions of this website are Copyrighted.
Your IP: 3.14.143.149     Referring URL:
Browser: Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Terms and Conditions, Privacy Policy, and Security Policy