martedì 28 gennaio 2014

[Powershell] How to output several objects from a function

Here: http://stackoverflow.com/questions/12620375/how-to-return-several-items-from-a-powershell-function

domenica 19 maggio 2013

Powershell and Oracle: the strange couple

Here it is a nice guide to query an OracleDB using Powershell.
Basically install an Oracle Client (with .NET support), and define and use the following function (courtesy of PoshCode comunity):


function Get-OLEDBData ($connectstring, $sql) {            
   $OLEDBConn = New-Object System.Data.OleDb.OleDbConnection($connectstring)            
   $OLEDBConn.open()            
   $readcmd = New-Object system.Data.OleDb.OleDbCommand($sql,$OLEDBConn)            
   $readcmd.CommandTimeout = '300'            
   $da = New-Object system.Data.OleDb.OleDbDataAdapter($readcmd)            
   $dt = New-Object system.Data.datatable            
   [void]$da.fill($dt)            
   $OLEDBConn.close()            
   return $dt            
}
 
 
A test is here:

$connString = "password=pwd;User ID=id;Data Source=ambarabaciccicocco;Provider=OraOLEDB.Oracle"            
$query= "SELECT * FROM HR.DEPARTMENTS"            
Get-OLEDBData -connection $connString -sql $query

Here are the guides:
http://guyharrison.typepad.com/oracleguy/2008/01/accessing-oracl.html
http://sev17.com/2010/02/28/querying-oracle-from-powershell-part-1/
http://cmille19.wordpress.com/2010/03/01/querying-oracle-from-powershell-part-2/

Enjoy!
Sayonara

lunedì 6 maggio 2013

XenServer 5.6 and prblem with the xapi service

If the xapi service cannot start, or experiencing some problem with the xsconsole, try this:

http://support.citrix.com/article/CTX128316

venerdì 13 gennaio 2012

Powershell and SQL "GO" separator

When executing a SQL statement in Powershell that contains words like "GO" it generates the error:

"Incorrect syntax near 'GO' "

The explanation stands in the fact that GO is not a SQL keyword. It's a batch separator used by client tools (like SSMS) to break the entire script up into batches.
The solutions may be to break up the script into batches, with a script like this:

private static List getCommands(string testDataSql)
{
string[] splitcommands = File.ReadAllText(testDataSql).Split(new string[]{"GO\r\n"}, StringSplitOptions.RemoveEmptyEntries);
List commandList = new List(splitcommands);
return commandList;
}

lunedì 28 novembre 2011

Problem with COSBI OpenSource Mark

If the workload does not work, it's usually a problem related to the fact that COSBI cannot write the .ini file.

The problem is associated to missing drivers. Install all the drivers needed, and all will work fine :)

sabato 26 novembre 2011

Repair SQL Server Database marked as Suspect or Corrupted

EXEC sp_resetstatus 'real_set_2'
ALTER DATABASE real_set_2 SET EMERGENCY
DBCC CheckDB ('real_set_2')
ALTER DATABASE real_set_2 SET SINGLE_USER WITH ROLLBACK IMMEDIATE
DBCC CheckDB ('real_set_2', REPAIR_ALLOW_DATA_LOSS)
ALTER DATABASE real_set_2 SET MULTI_USER

mercoledì 23 novembre 2011

Windows XP Activation LOOP

To solve the loop, while we are trying to activate, press Windows Key + U, then in the window that pops up press the link to the Microsoft Website, and you will have a nice browser that will fulfill your desires :)

(source: http://www.thetomorrowtimes.com/2006/12/how-to-login-to-expired-windows.html)