![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Storedprocedure Parameter from Host Hello I would like set HostName as Parameter When I gife as cleartext, then is ok. show <<<< OK I would like automatic from lokal host? How do that? Thanks Gregor $strServer = "." $HostName = get-WmiObject -class "Win32_ComputerSystem" -namespace "root\CIMV2" -computername $strServer | select DNSHostName #SQL Connection create $conn = new-object System.Data.SqlClient.SqlConnection $conn.ConnectionString = "server=..xxx" $cmd = new-object System.Data.SqlClient.SqlCommand("spCreateQueue", $conn) $cmd.CommandType = [System.Data.CommandType]'StoredProcedure' #$cmd.Parameters.Add("@PrintServerName","hsb990te") <<<< This linke is OK $cmd.Parameters.Add("@PrintServerName",""+$HostName) <<<< No OK??????? $cmd.Connection = $conn $adapter = new-object System.Data.SqlClient.SqlDataAdapter $adapter.SelectCommand = $cmd $ds = new-object System.Data.DataSet $adapter.Fill($ds) $conn.close() #DataTable create $dt = new-object "System.Data.DataTable" "dtData" $dt = $ds.Tables[0] #View $dt | FOREACH-OBJECT { " " + $_.QueueName + ": " + $_.QueueTemplate + ": " + $_.QueueRegFile + ": " + $_.PrinterType + ": " + $_.location + ": " + $_.PrintServer + ": " + $_.PrintServerShort} |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Storedprocedure Parameter from Host You can get the local computer name via the environment psdrive: $env:COMPUTERNAME ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com Quote: > Hello > > I would like set HostName as Parameter > When I gife as cleartext, then is ok. show <<<< OK > I would like automatic from lokal host? How do that? > > Thanks > Gregor > $strServer = "." > $HostName = get-WmiObject -class "Win32_ComputerSystem" -namespace > "root\CIMV2" -computername $strServer | select DNSHostName > #SQL Connection create > $conn = new-object System.Data.SqlClient.SqlConnection > $conn.ConnectionString = "server=..xxx" > $cmd = new-object System.Data.SqlClient.SqlCommand("spCreateQueue", > $conn) > $cmd.CommandType = [System.Data.CommandType]'StoredProcedure' > #$cmd.Parameters.Add("@PrintServerName","hsb990te") <<<< > This > linke is OK > $cmd.Parameters.Add("@PrintServerName",""+$HostName) <<<< No > OK??????? > $cmd.Connection = $conn > $adapter = new-object System.Data.SqlClient.SqlDataAdapter > $adapter.SelectCommand = $cmd > $ds = new-object System.Data.DataSet > $adapter.Fill($ds) > $conn.close() > #DataTable create > $dt = new-object "System.Data.DataTable" "dtData" > $dt = $ds.Tables[0] > #View > $dt | FOREACH-OBJECT { " " + $_.QueueName + ": " + $_.QueueTemplate + > ": " + > $_.QueueRegFile + ": " + $_.PrinterType + ": " + $_.location + ": " + > $_.PrintServer + ": " + $_.PrintServerShort} |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Storedprocedure Parameter from Host Thanks for you help - its now ok :-) Gregor "Shay Levi" <no@xxxxxx> wrote in message news:8766a9441f2c18ca3d18c8056162@xxxxxx Quote: > > You can get the local computer name via the environment psdrive: > > $env:COMPUTERNAME > > > > ----- > Shay Levi > $cript Fanatic > http://scriptolog.blogspot.com > Quote: >> Hello >> >> I would like set HostName as Parameter >> When I gife as cleartext, then is ok. show <<<< OK >> I would like automatic from lokal host? How do that? >> >> Thanks >> Gregor >> $strServer = "." >> $HostName = get-WmiObject -class "Win32_ComputerSystem" -namespace >> "root\CIMV2" -computername $strServer | select DNSHostName >> #SQL Connection create >> $conn = new-object System.Data.SqlClient.SqlConnection >> $conn.ConnectionString = "server=..xxx" >> $cmd = new-object System.Data.SqlClient.SqlCommand("spCreateQueue", >> $conn) >> $cmd.CommandType = [System.Data.CommandType]'StoredProcedure' >> #$cmd.Parameters.Add("@PrintServerName","hsb990te") <<<< >> This >> linke is OK >> $cmd.Parameters.Add("@PrintServerName",""+$HostName) <<<< No >> OK??????? >> $cmd.Connection = $conn >> $adapter = new-object System.Data.SqlClient.SqlDataAdapter >> $adapter.SelectCommand = $cmd >> $ds = new-object System.Data.DataSet >> $adapter.Fill($ds) >> $conn.close() >> #DataTable create >> $dt = new-object "System.Data.DataTable" "dtData" >> $dt = $ds.Tables[0] >> #View >> $dt | FOREACH-OBJECT { " " + $_.QueueName + ": " + $_.QueueTemplate + >> ": " + >> $_.QueueRegFile + ": " + $_.PrinterType + ": " + $_.location + ": " + >> $_.PrintServer + ": " + $_.PrintServerShort} > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Re: Hiding the Host OS when startng MS VPC with host | Virtual PC | |||
| Using multiple Parameter sets for a Parameter | PowerShell | |||
| VirtualPC VM created in XP host hangs in Vista host | Virtual PC | |||
| How to best control parameter attributes and parameter parsing in your own scripts? | PowerShell | |||
| Read-Host issue, won't store to variable when using multiple read-host lines | PowerShell | |||