quick and dirty script to edit lots of files and keep a log


First I built a list of files $FileList=dir -recurse C:\temp\folderx -Attributes !Directory | ? name -notlike ‘*exe’ | ? name -notlike ‘*dll’| select fullname Then for each one, record the name to a log file, edit it and prompt for and store a comment foreach ($F in $Filelist) {$F.Fullname >> commentlog.txt; $File = $F.Fullname; C:\Progra~2\vim\vim74\gvim.exe … Read more

getting a list of aliases ordered by the aliasee


This is fairly trivial…and I’ve no idea if ‘aliasee‘ is a real word or not, but I found this quite useful today: get-alias | select ResolvedCommand, name | sort -property resolvedcommand On my laptop, this gives: ResolvedCommand Name ————— —- Add-Content ac Add-PSSnapin asnp Clear-Content clc Clear-History clhy Clear-Host cls Clear-Host clear Clear-Item cli Clear-ItemProperty … Read more

show sql errorlog messages since a specified date


This almost speaks for itself…but it might be worth noting that: I’m only interogating the latest file here it’s a teeny bit cumbersome – I would probably function-alize it the big advantage here compared to the GUI is you can cut-and-paste it _really easily_ $logs = dir sqlserver:\sql\_the_server_name $logs.readerrorlog(0) | where logdate -gt ([datetime]::ParseExact(’25/02/2015 07:27:36′,”dd/MM/yyyy … Read more

github and penflip


The github commands to edit a Penflip markdown document: git clone https://www.penflip.com/mattypenny/a-unix-persons-guide-to-powershell.git cd a-unix* gvim commands-summary.txt git add commands-summary.txt git commit -m ‘trying out penflip from the commandline :)’ git push -u origin master I downloaded Markdown Viewer add-on for Firefox, but this didn’t quite work with the down-loaded penflip document. The viewer only renders … Read more

system databases not included in powershell sqlserver provider ‘databases’ folder


I hadn’t noticed this before. If you do a dir listing of the databases for an instance within the Powershell Sqlserver provider, it doesn’t show the system databases PS C:\powershell> dir SQLSERVER:\SQL\my_pc\inst2012\databases Name Status Recovery Model CompatLvl Collation Owner —- —— ————– ——— ——— —– AdventureWorks2012 Normal Simple 110 SQL_Latin1_General_CP1_CI_AS matty TSQL2012 Normal Full 110 … Read more