PowerShell Variables
15.06.2009
A good source of information.
http://www.computerperformance.co.uk/powershell/powershell_variables.htm
15.06.2009
A good source of information.
http://www.computerperformance.co.uk/powershell/powershell_variables.htm
A quick script to connect to an sql sserver and get the information from a table. In this case find the SQL Proxy accounts from the msdb database.
# SQL Server and Database Information
$SqlServer = “.”;
$SqlCatalog = “msdb”;# SQL Query Statement
$q= “EXEC dbo.sp_help_proxy”
$cn = new-object system.data.SqlClient.SqlConnection(“Data Source=$SqlServer;Integrated Security=SSPI;Initial Catalog=$SqlCatalog”);
$ds = new-object “System.Data.DataSet” “dbo”$da = new-object “System.Data.SqlClient.SqlDataAdapter” ($q, $cn)
$junk = $da.Fill($ds)
$proxyAccounts = new-object “System.Data.DataTable” “dtPersonData”
$proxyAccounts = $ds.Tables[0]$proxyAccounts | FOREACH-OBJECT {“” + $_.Name}
22.12.2008
A quick script to compare two arrays.
$arrFirst = get-content First.txt
$arrSecond = get-content Second.txtNew-Item “C:MyworkplacepsFirstInSecond.txt” -Type file
New-Item “C:MyworkplacepsFirstNotInSecond” -Type fileForeach ($First in $arrFirst)
{
If ($arrSecond -contains $First)
{Add-content “C:MyworkplacepsFirstInsecond.txt” $First}
Else
{Add-content “C:MyworkplacepsFirstNotInSecond.txt” $First}