Difference between revisions of "PowerShell Examples"

Jump to navigation Jump to search
500 bytes added ,  13:29, 18 April 2012
Added Depreciated template
(Added "SSH Client")
(Added Depreciated template)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Depreciated|category=PowerShell}}
== Excel ==
== Excel ==
Basic example, converting an esxisting CSV file into a XLSX file...
Basic example, converting an esxisting CSV file into a XLSX file...
Line 34: Line 36:


=== Formatting ===
=== Formatting ===
{|cellpadding="1" cellspacing="0" border="1"
{|class="vwikitable"
|- style="background-color:#bbddff;"
|-  
! Example                                                        !! Description
! Example                                                        !! Description
|-
|-
Line 301: Line 303:
$cmd = New-Object MySql.Data.MySqlClient.MySqlCommand("USE $database", $conn)
$cmd = New-Object MySql.Data.MySqlClient.MySqlCommand("USE $database", $conn)
</source>
</source>
=== Test for NULL ===
In order to be able to test for a NULL value in a set of results from a query, you need to compare against a specific DB NULL value.  Otherwise you'll get an error similar to...
<code> Error: "Cannot convert the "0" value of type "System.Int32" to type "System.DBNull" </code>
So to correctly test, use the following...
<source lang="powershell">
if ([System.DBNull]::Value.Equals($db_query_result)) {
    Write-Host "Result is NULL"
}
</source>
The above was sourced from http://blogs.technet.com/b/industry_insiders/archive/2008/09/15/testing-for-database-null-values-from-powershell.aspx


== Scheduling ==
== Scheduling ==
Line 495: Line 510:
$SshClient.Dispose()
$SshClient.Dispose()
</source>
</source>
[[Category:PowerShell]]
[[Category:MySQL]]
[[Category:SMTP]]
[[Category:FTP]]
[[Category:SSH]]

Navigation menu