Basic Powershell Snippets

Michael Bourgon has a few Powershell snippets he wrote this week:

I needed to parse out a Unix filename from a file.  The original “ls” looked like this:

-rw-rw-r– 1 psabcderfg data 646621 Jul 19 16:25 myfile16071901.Z

The unix command to parse it would
cat $fl |awk ‘{print $9}’

And the powershell equivalent is:
$newfiles = get-content $fl | foreach {$_.split(” “)[8]}
(the number is 8 instead of 9 because powershell arrays start at 0)

Check all of them out.

Related Posts

Config Options For Checks In DBAChecks

Rob Sewell explains a new features in dbachecks: You can see the name, the current value and the description Ah thats cool he said so How Do I Know Which Configuration Is For Which Check? Well, you just…. , you know…… AHHHHHHH Rob then made this possible.  Click through to see how you can determine […]

Read More

Creating Azure SQL Database Managed Instances Via ARM Templates

Jovan Popovic shows how us how to build a Managed Instance of Azure SQL Database using Powershell and an ARM template: Values that you need to change in this request are: name – name of your Azure SQL Managed Instance (don’t include domain). properties/administratorLogin – SQL login that will be used to connect to the […]

Read More

Categories

August 2016
MTWTFSS
« Jul Sep »
1234567
891011121314
15161718192021
22232425262728
293031