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

imagep039

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

imagep083a

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

market

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

imagep033

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

imagep030

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

70-461 – notes from ch. 2 – identity, newId, newSequentialId and sequences

imagep027

_identity_ is set up as ‘int identity‘ in the create table newid() is functionally similar but you get a 36 character field newsequentialid is like newid but you can see a sequntial increase sequences are like in Oracle Identity To use the automatic identity thing: drop table aa.tax_dodgers; create table aa.tax_dodgers (id1 int identity, name … Read more