Monthly Archives: December 2009

Online PowerShell help

One of the reasons I dump the file files to text files is that I am frequently in a position of being on a customer site without direct Internet access.  If I have the files available then I can solve … Continue reading

Posted in PowerShell V2 | Leave a comment

Module Help Files

The use of modules to supply PowerShell based functionality in Windows 7Windows 2008 R2 makes accessing the help files a little bit problematic. We have to have the module loaded to access the file.  Sometimes I want to think through … Continue reading

Posted in PowerShell V2 | Leave a comment

Access Functions

I have put the module of Access functions I’ve been blogging about over the last few weeks onto my SkyDrive at http://cid-43cfa46a74cf3e96.skydrive.live.com/browse.aspx/PowerShell%20Scripts/AccessFunctions The usual warnings apply. This is a work in progress and subject to change.  All scripts, and the … Continue reading

Posted in PowerShell V2 | 7 Comments

Proxy for import-module

I do quite a lot with modules as you can tell from my posts over the last few months and have bit a fair collection of modules. One issue I find when loading a module is that I can’t always … Continue reading

Posted in PowerShell V2 | Leave a comment

WMI migration

In case you were wondering why the WMI based posts seem to have dried up – I have opened a new blog http://itknowledgeexchange.techtarget.com/powershell/ Just for PowerShell and WMI. I figure there is enough subject matter in the topic to support … Continue reading

Posted in PowerShell and WMI | Leave a comment

Delete Access Table

This times lets go mad and delete a whole table. 001002003004005006007008009010011 function Remove-AccessTable {[CmdletBinding(SupportsShouldProcess=$true)]param (    [string]$table,    [System.Data.OleDb.OleDbConnection]$connection)    $sql = "DROP TABLE $table "    $cmd = New-Object System.Data.OleDb.OleDbCommand($sql, $connection)        if ($psCmdlet.ShouldProcess("$($connection.DataSource)", "$sql")){$cmd.ExecuteNonQuery()}} Again we use the SupportsShouldProcess – have to love the amount of functionality we get for one line of … Continue reading

Posted in Powershell | Leave a comment

Delete an Access Column

We have seen how to add a column to our access database – what about removing a column? 001002003004005006007008009010011012 function Remove-AccessColumn {[CmdletBinding(SupportsShouldProcess=$true)]param (    [string]$table,    [string]$column,    [System.Data.OleDb.OleDbConnection]$connection)    $sql = "ALTER TABLE $table DROP COLUMN $column"    $cmd = New-Object System.Data.OleDb.OleDbCommand($sql, $connection)        if ($psCmdlet.ShouldProcess("$($connection.DataSource)", "$sql")){$cmd.ExecuteNonQuery()}}   We use the SupportsShouldProcess=$true to get the … Continue reading

Posted in Powershell | Leave a comment

Add a column to an Access Table

Now we have created our Table we can start adding columns 001002003004005006007008009010011012013014015016017018019020021022023024025026027028029030031032033034035036037038039040041042043044045046047048049050051052053054055056057058059060061062063064065066067068069070071072073074075076077078079080081082083084085086 function New-AccessColumn {[CmdletBinding()]param (    [System.Data.OleDb.OleDbConnection]$connection,    [string]$table,    [switch]$notnull,     [parameter(ParameterSetName="datetime")]      [string]$dtname,     [parameter(ParameterSetName="unique")]      [string]$uniquename,     [parameter(ParameterSetName="binary")]      [string]$binname,     [parameter(ParameterSetName="bit")]      [string]$bitname,     [parameter(ParameterSetName="tinyinteger")]      [string]$tnyintname,     [parameter(ParameterSetName="smallinteger")]      [string]$smlintname,   … Continue reading

Posted in Powershell | Leave a comment

New Access Table

I have already presented a function to create a new access table but I wasn’t very happy with it because we had to supply the full table creation SQL script. I have altered that function so it creates an empty … Continue reading

Posted in Powershell | Leave a comment

Creating Objects

There is a post on the PowerShell Team blog about using New-Object – http://blogs.msdn.com/powershell/archive/2009/12/05/new-object-psobject-property-hashtable.aspx The –property parameter discussed in this post is something that I had only come across recently.  In a number of recent posts I have used Add-Type … Continue reading

Posted in PowerShell V2 | Leave a comment