Below is my Sample Code
$scon2 = New-Object System.Data.SqlClient.SqlConnection
$scon2.ConnectionString = "$sconstring"
$cmd3 = New-Object System.Data.SqlClient.SqlCommand
$cmd3.Connection = $scon2
$cmd3.CommandType = [System.Data.CommandType]::StoredProcedure
$cmd3.CommandText = "sp_replmonitorsubscriptionpendingcmds"
$cmd3.Parameters.Add("@publisher",[System.Data.CommandType]::NVarChar)
$cmd3.Parameters.Add("@publisher_db",[System.Data.CommandType]::NVarChar)
$cmd3.Parameters.Add("@publication",[System.Data.CommandType]::NVarChar)
$cmd3.Parameters.Add("@subscriber",[System.Data.CommandType]::NVarChar)
$cmd3.Parameters.Add("@subscriber_db",[System.Data.CommandType]::NVarChar)
$cmd3.Parameters.Add("@subscription_type",[System.Data.CommandType]::Int)
$cmd3.CommandTimeout = 0
$scon2.Open()
From the above Code Everything Works fine but these below code of lines
$cmd3.Parameters.Add(“@publisher”,[System.Data.CommandType]::NVarChar)
$cmd3.Parameters.Add(“@publisher_db”,[System.Data.CommandType]::NVarChar)
$cmd3.Parameters.Add(“@publication”,[System.Data.CommandType]::NVarChar)
$cmd3.Parameters.Add(“@subscriber”,[System.Data.CommandType]::NVarChar)
$cmd3.Parameters.Add(“@subscriber_db”,[System.Data.CommandType]::NVarChar)
$cmd3.Parameters.Add(“@subscription_type”,[System.Data.CommandType]::Int)
is writing the below information (which i dont want) to the console (am using Write-Host ) of power shell
AllowDBNull : True
AutoIncrement : False
AutoIncrementSeed : 0
AutoIncrementStep : 1
Caption : DataBaseName
ColumnName : DataBaseName
Prefix :
DataType : System.String
DateTimeMode : UnspecifiedLocal
DefaultValue :
Expression :
ExtendedProperties : {}
MaxLength : -1
Namespace :
Ordinal : 0
ReadOnly : False
Table : {}
Unique : False
ColumnMapping : Element
Site :
Container :
DesignMode : False
-------- below this my actual output comes as below-------------
From DUBIS3DVSQLP01\VIP01 To CHENS3DVSQLP01\VIP01
DataBaseName DataBaseType PendingTXns Estimated Time(Sec)
HDR9_CDB Catalog 0 0
HDR9_CDB_SCHEMA CatalogSchema 0 0
SONPD_MDB Model 0 0
HDR9_SDB Site 0 0
HDR9_SDB_SCHEMA SiteSchema 0 0
From DUBIS3DVSQLP01\VIP01 To SAUDS3DVSQLP01\VIP01
DataBaseName DataBaseType PendingTXns Estimated Time(Sec)
HDR9_CDB Catalog 0 0
HDR9_CDB_SCHEMA CatalogSchema 0 0
SONPD_MDB Model 0 0
HDR9_SDB Site 0 0
HDR9_SDB_SCHEMA SiteSchema 0 0
- Can any one please advise me how to get rid of that unnecessary stuff written on power shell console
- I have done using Cls but this will wipe entire my results and it will show only last result (as am calling this through a function in script three times).