SQL 2008 and powershell - with the 2008 releases from microsoft powershell is really making its way into the mainstream. sql server 2008 ships with standard powershell as well as an add-in that provides an interesting degree of integration that will allow DBAs to write scripts that are far more generalized than T-SQL scripts. getting ready to play with it is pretty strait forward. all you have to do is click the "Start PowerShell" context menu option which is relatively ubiquitous in SSMS 2008's object explorer, located on the "Tables" folder within a database for example. essentially the schematic structure of database is layed out into a virtual filesystem with database objects represented as files and directories. for example every table is a directory with subdirectories for each column and each column having files for the...
Asynchronous and remote execution with powershell 2 ctp3 - An interesting feature released with the PowerShell 2 CTP3 is the ability to run background jobs consisting of arbitrary PowerShell code. In order to use this functionality you must download and install the PowerShell 2 CTP3 and the WinRM (Windows Remote Management) 2.0 CTP. Keep in mind that installing the CTP requires uninstalling previous versions of PowerShell. Depending on the PowerShell and operating system versions involved the procedure can vary. Google/Bing is your friend. Once bringing up PowerShell you have to enable remoting by invoking the aptly named Enable-PSRemoting cmdlet Enable-PSRemoting -force Now the meat. Consider the following code: # copy bigfile.txt on a background thread $job = start-job -scriptBlock { cp bigfile.txt bigfilecopy.txt } # here's where we'd perform some other logic while our file copies # wait for job...
PowerShell 2.0 Out-GridView, ISE and ScriptCmdlets - In my last post I discussed the background-job and remoting systems of PowerShell 2.0. While I find those features interesting personally there are three more that I'd like to discuss that have a broader appeal: the Out-GridView CmdLet, ScriptCmdlets and the PowerShell Integrated Scripting Environment (ISE). Note that PowerShell 2.0 is in CTP 3 at the time of writing and everything is subject to change. Out-GridView The Out-GridView cmdlet gives you a lightwieight sortable/searchable grid that you can easily pipe collections into as demonstrated below. ls | Out-GridView ScriptCmdlets Previously the only way to develop your own Cmdlets was to resort to one of the higher level .Net languages such as VB.Net and C#. This restriction has been removed with the introduction of ScriptCmdlets. Consider the following ScriptCmdLet that retrieves a...











