import-CSV - test-connection

Hello,
im kinda run of ideas although i believe the solution must be simple.

I have CSV, containing 3 columns. 

hvserver;virtserver;iLO
hvserver1;virtserver1;10.0.0.1
hvserver2;virtserver2;10.55.254.5
hvserver3;virtserver4;10.0.0.1
;virtserver4;

I want to check physical and virtual server for port 3389  (open/closed) and ilo for IP address availability.
For checking RDP i use this code:

$Connection = New-Object Net.Sockets.TcpClient
   try{
    $Connection.Connect($server,"3389")
    if ($Connection.Connected){
     $Response = Open
     $Connection.Close()
     }
    }
   catch [System.Management.Automation.MethodInvocationException]{
    $Response = Closed/Filtered
    }

For iLo:

Test-Connection -ComputerName $line.ilo -Quiet -Count 2

For single input  (just computernames ) its easy ..

$servers = "server1.domain.com","localhost","","server4.domain.com"
$TCPObject = @()
foreach ($server in $servers)
{
 if ($server){
  $Connection = New-Object Net.Sockets.TcpClient
  try {
   $Connection.Connect($server,"3389")
   if ($Connection.Connected) {
    $Response = Open
    $Connection.Close()
    }
   }
  catch [System.Management.Automation.MethodInvocationException]
   {
   $Response = Closed/Filtered
   }
 $hash = @{
  Server = $server
  Response = $Response
  }
 $Object = New-Object PSObject -Property $hash
 $TCPObject += $Object 
 }
 else {
  $hash = @{
   Server = $server
   Response = Closed/Filtered
   }
  $Object = New-Object PSObject -Property $hash
  $TCPObject += $Object 
  }
 }
$TCPObject |ft -AutoSize

I am having trouble with CSV as input file and having the following result:

HVserver;ResonseHV;VirtServer;ResponseVirt;IloIPAddress;iLOValid

hvserver1 Closed/Filtered virtserver1 Closed/Filtered 10.0.0.1        False
hvserver2 Closed/Filtered virtserver2 Closed/Filtered 10.20.254.5      True
hvserver3 Closed/Filtered virtserver4 Closed/Filtered 10.0.0.1        False
hvserver3 Closed/Filtered virtserver4 Closed/Filtered 10.0.0.1        False

I understand, I need to start with
$servers = import-csv .\source.csv -delimiter ";"
Foreach ($line in $servers){
$hv = $line.hvserver
$virt = $line.virtserver
$ilo = $line.ilo
}
 .. after that. I just get buggy results. I think I need add some IF/Else conditions or something like that.

I need advice how to make my custom hash table with all 5 columns with required output.  
Note: some info on input CSV might be missing, as some servers don't have iLO or doenst host any virtual server..

July 23rd, 2015 4:18am

Looks like i got it
$servers = import-csv .\connsource.csv -Delimiter ";"
$TCPObject = @()

foreach ($line in $servers)
{
 $hv = $line.hvserver
 $virt   = $line.virtserver
 $ilo   = $line.ilo
  
  if ($hv){
   $Connection = New-Object Net.Sockets.TcpClient
   try{
    $Connection.Connect($hv,"3389")
    if ($Connection.Connected){
     $Responsehv = Open
     $Connection.Close()
     }
    }
   catch [System.Management.Automation.MethodInvocationException]{
    $Responsehv = Closed/Filtered
    }
   }
   else {
    $hv = ""
    $Responsehv = "
    }
  
  if ($virt){
   $Connection = New-Object Net.Sockets.TcpClient
   try{
    $Connection.Connect($virt,"3389")
    if ($Connection.Connected){
     $Responsevirt = Open
     $Connection.Close()
     }
    }
   catch [System.Management.Automation.MethodInvocationException]{
    $Responsevirt = Closed/Filtered
    }
   }
   else {
    $virt = ""
    $Responsevirt = ""}
  
  if ($ilo){
   $ilovalid = Test-Connection -ComputerName $line.ilo -Quiet -Count 2
   }
   else {
    $ilo = ""
    $ilovalid = ""
    }
    
  $hash = @{
    hv = $hv
    virt =  $virt
    ResponseHVB = $Responsehv
    Responsevirt = $Responsevirt
    iLOIpAddress = $ilo
    iLOValid = $ilovalid
    }
   $Object = New-Object PSObject -Property $hash
  $TCPObject += $Object 
 }
$TCPObject |select hv,responseHVB,virt,responsevirt,iloipaddress,IloValid |sort |ft -AutoSize

  • Proposed as answer by clayman2 18 hours 43 minutes ago
  • Marked as answer by Mekac 18 hours 31 minutes ago
Free Windows Admin Tool Kit Click here and download it now
July 23rd, 2015 7:05am

Glad you got it working, also this is not needed

 $hv = $line.hvserver
 $virt   = $line.virtserver
 $ilo   = $line.ilo

You can just access the data with $line.<property>, saving it to another variable just waste memory, even though in this situation, it is not much. The only time I see when it is necessary to save to a variable, is when you go through the pipeline multiple times, so for instance

Import-Csv C:\somefile.csv | Foreach {
  $someProperty = $_.PropertyHeaderFromCsv

  Some-CmdletOrOtherWork | Foreach {
    Some-CmdletOrOtherWork -Property $someProperty -AnotherProperty $_
  }
}

This is because on each pipe $_ will become a new object and you lose your previous one.

July 23rd, 2015 8:28am

Here is a cleaner version....the tcp connection information I just put into a function

function Test-TcpConnection {
  [CmdletBinding()]
  Param (
    [Parameter(Mandatory=$true)]
    [string] $ComputerName,
	[Parameter(Mandatory=$true)]
	[string]$PortNumber
  )
  Begin {
    $conn = New-Object Net.Sockets.TcpClient
  }
  Process {
    try {
      $conn.Connect($ComputerName, $PortNumber)
	
	  if ($conn.Connected) {
	    Write-Output "Open"
	  }
	}
	catch [System.Management.Automation.MethodInvocationException] {
	  Write-Output "Closed/Filtered"
	}
  }
  End {
    $conn.Close()
	$conn = $null
  }
}

$tcpObjects = @()

Import-Csv .\connsource.csv -Delimiter ";" | ForEach-Object {
  if ($_.hvserver) {
    $hvResponse = Test-TcpConnection -ComputerName $_.hvserver -PortNumber "3389"
  }
  elseif ($_.virtserver) {
    $virtResponse = Test-TcpConnection -ComputerName $_.virtserver -PortNumber "3389"
  }
  elseif ($_.ilo) {
    $iloResponse = Test-Connection -ComputerName $_.ilo -Quiet -Count 2
  }
  
  $responseHash = @{
    HV = $_.hvserver
    Virt =  $_.virtserver
    ResponseHVB = $hvResponse
    ResponseVirt = $virtResponse
    iLOIpAddress = $_.ilo
    iLOValid = $iloResponse
  }
  
  $object = New-Object PSObject -Property $responseHash
  $tcpObjects += $object
}

$tcpObjects | Select-Object HV,ResponseHVB,Virt,ResponseVirt,iLOIpAddress,iLOValid | Sort-Object | Format-Table -AutoSize

Free Windows Admin Tool Kit Click here and download it now
July 23rd, 2015 9:01am

Looks like i got it
$servers = import-csv .\connsource.csv -Delimiter ";"
$TCPObject = @()

foreach ($line in $servers)
{
 $hv = $line.hvserver
 $virt   = $line.virtserver
 $ilo   = $line.ilo
  
  if ($hv){
   $Connection = New-Object Net.Sockets.TcpClient
   try{
    $Connection.Connect($hv,"3389")
    if ($Connection.Connected){
     $Responsehv = Open
     $Connection.Close()
     }
    }
   catch [System.Management.Automation.MethodInvocationException]{
    $Responsehv = Closed/Filtered
    }
   }
   else {
    $hv = ""
    $Responsehv = "
    }
  
  if ($virt){
   $Connection = New-Object Net.Sockets.TcpClient
   try{
    $Connection.Connect($virt,"3389")
    if ($Connection.Connected){
     $Responsevirt = Open
     $Connection.Close()
     }
    }
   catch [System.Management.Automation.MethodInvocationException]{
    $Responsevirt = Closed/Filtered
    }
   }
   else {
    $virt = ""
    $Responsevirt = ""}
  
  if ($ilo){
   $ilovalid = Test-Connection -ComputerName $line.ilo -Quiet -Count 2
   }
   else {
    $ilo = ""
    $ilovalid = ""
    }
    
  $hash = @{
    hv = $hv
    virt =  $virt
    ResponseHVB = $Responsehv
    Responsevirt = $Responsevirt
    iLOIpAddress = $ilo
    iLOValid = $ilovalid
    }
   $Object = New-Object PSObject -Property $hash
  $TCPObject += $Object 
 }
$TCPObject |select hv,responseHVB,virt,responsevirt,iloipaddress,IloValid |sort |ft -AutoSize

  • Proposed as answer by clayman2 Thursday, July 23, 2015 12:26 PM
  • Marked as answer by Mekac Thursday, July 23, 2015 12:38 PM
July 23rd, 2015 11:03am

Looks like i got it
$servers = import-csv .\connsource.csv -Delimiter ";"
$TCPObject = @()

foreach ($line in $servers)
{
 $hv = $line.hvserver
 $virt   = $line.virtserver
 $ilo   = $line.ilo
  
  if ($hv){
   $Connection = New-Object Net.Sockets.TcpClient
   try{
    $Connection.Connect($hv,"3389")
    if ($Connection.Connected){
     $Responsehv = Open
     $Connection.Close()
     }
    }
   catch [System.Management.Automation.MethodInvocationException]{
    $Responsehv = Closed/Filtered
    }
   }
   else {
    $hv = ""
    $Responsehv = "
    }
  
  if ($virt){
   $Connection = New-Object Net.Sockets.TcpClient
   try{
    $Connection.Connect($virt,"3389")
    if ($Connection.Connected){
     $Responsevirt = Open
     $Connection.Close()
     }
    }
   catch [System.Management.Automation.MethodInvocationException]{
    $Responsevirt = Closed/Filtered
    }
   }
   else {
    $virt = ""
    $Responsevirt = ""}
  
  if ($ilo){
   $ilovalid = Test-Connection -ComputerName $line.ilo -Quiet -Count 2
   }
   else {
    $ilo = ""
    $ilovalid = ""
    }
    
  $hash = @{
    hv = $hv
    virt =  $virt
    ResponseHVB = $Responsehv
    Responsevirt = $Responsevirt
    iLOIpAddress = $ilo
    iLOValid = $ilovalid
    }
   $Object = New-Object PSObject -Property $hash
  $TCPObject += $Object 
 }
$TCPObject |select hv,responseHVB,virt,responsevirt,iloipaddress,IloValid |sort |ft -AutoSize

  • Proposed as answer by clayman2 Thursday, July 23, 2015 12:26 PM
  • Marked as answer by Mekac Thursday, July 23, 2015 12:38 PM
Free Windows Admin Tool Kit Click here and download it now
July 23rd, 2015 11:03am

Here is a cleaner version....the tcp connection information I just put into a function

function Test-TcpConnection {
  [CmdletBinding()]
  Param (
    [Parameter(Mandatory=$true)]
    [string] $ComputerName,
	[Parameter(Mandatory=$true)]
	[string]$PortNumber
  )
  Begin {
    $conn = New-Object Net.Sockets.TcpClient
  }
  Process {
    try {
      $conn.Connect($ComputerName, $PortNumber)
	
	  if ($conn.Connected) {
	    Write-Output "Open"
	  }
	}
	catch [System.Management.Automation.MethodInvocationException] {
	  Write-Output "Closed/Filtered"
	}
  }
  End {
    $conn.Close()
	$conn = $null
  }
}

$tcpObjects = @()

Import-Csv .\connsource.csv -Delimiter ";" | ForEach-Object {
  if ($_.hvserver) {
    $hvResponse = Test-TcpConnection -ComputerName $_.hvserver -PortNumber "3389"
  }
  
if ($_.virtserver) { $virtResponse = Test-TcpConnection -ComputerName $_.virtserver -PortNumber "3389" }
if ($_.ilo) { $iloResponse = Test-Connection -ComputerName $_.ilo -Quiet -Count 2 } $responseHash = @{ HV = $_.hvserver Virt = $_.virtserver ResponseHVB = $hvResponse ResponseVirt = $virtResponse iLOIpAddress = $_.ilo iLOValid = $iloResponse } $object = New-Object PSObject -Property $responseHash $tcpObjects += $object } $tcpObjects | Select-Object HV,ResponseHVB,Virt,ResponseVirt,iLOIpAddress,iLOValid | Sort-Object | Format-Table -AutoSize
July 23rd, 2015 12:59pm

Here is a cleaner version....the tcp connection information I just put into a function

function Test-TcpConnection {
  [CmdletBinding()]
  Param (
    [Parameter(Mandatory=$true)]
    [string] $ComputerName,
	[Parameter(Mandatory=$true)]
	[string]$PortNumber
  )
  Begin {
    $conn = New-Object Net.Sockets.TcpClient
  }
  Process {
    try {
      $conn.Connect($ComputerName, $PortNumber)
	
	  if ($conn.Connected) {
	    Write-Output "Open"
	  }
	}
	catch [System.Management.Automation.MethodInvocationException] {
	  Write-Output "Closed/Filtered"
	}
  }
  End {
    $conn.Close()
	$conn = $null
  }
}

$tcpObjects = @()

Import-Csv .\connsource.csv -Delimiter ";" | ForEach-Object {
  if ($_.hvserver) {
    $hvResponse = Test-TcpConnection -ComputerName $_.hvserver -PortNumber "3389"
  }
  elseif ($_.virtserver) {
    $virtResponse = Test-TcpConnection -ComputerName $_.virtserver -PortNumber "3389"
  }
  elseif ($_.ilo) {
    $iloResponse = Test-Connection -ComputerName $_.ilo -Quiet -Count 2
  }
  
  $responseHash = @{
    HV = $_.hvserver
    Virt =  $_.virtserver
    ResponseHVB = $hvResponse
    ResponseVirt = $virtResponse
    iLOIpAddress = $_.ilo
    iLOValid = $iloResponse
  }
  
  $object = New-Object PSObject -Property $responseHash
  $tcpObjects += $object
}

$tcpObjects | Select-Object HV,ResponseHVB,Virt,ResponseVirt,iLOIpAddress,iLOValid | Sort-Object | Format-Table -AutoSize
Free Windows Admin Tool Kit Click here and download it now
July 24th, 2015 3:17am

You are correct, my apologies. I have update the script.
July 24th, 2015 6:57pm

Ive modified it for running via background jobs  (for faster results)

Param ([int]$BatchSize=2)
 #list of servers
$source = import-csv .\connsource.csv -Delimiter ";"

$elapsedTime = [system.diagnostics.stopwatch]::StartNew()
$result = @()
$itemCount = 0

## checking running jobs 
if (get-job|? {$_.name -like "Script*"}){
    write-host "ERROR: There are pending background jobs in this session:" -back red -fore white
    get-job |? {$_.name -like "Script*"} | out-host
    write-host "REQUIRED ACTION: Remove the jobs and restart this script" -back black -fore yellow
    $yn = read-host "Automatically remove jobs now?"
    if ($yn -eq "y"){
        get-job|? {$_.name -like "Script*"}|% {remove-job $_}
        write-host "jobs have been removed; please restart the script" -back black -fore green
        }
    exit
    }
$i = 0

$itemCount = $source.count
write-host "Script started at $(get-date -uFormat "%Y/%m/%d %H:%M:%S")".padright(60)             -back darkgreen -fore white
write-host "                    (contains $itemCount unique entries)" -back black -fore green
$activeJobCount = 0
$totalJobCount = 0
write-host "Submitting background jobs..." -back black -fore yellow
for ($i=0; $i -lt $itemCount;$i += $batchSize){
    $activeJobCount += 1; $totalJobCount += 1; $HostList = @()
    $HostList += $source |select -skip $i -first $batchsize
    $j = start-job -InitializationScript {
    function Test-TcpPortConnection {
  [CmdletBinding()]
  Param (
    [Parameter(Mandatory=$true)]
    [string] $ComputerName,
	[Parameter(Mandatory=$true)]
	[string]$PortNumber
  )
  Begin {
    $conn = New-Object Net.Sockets.TcpClient
  }
  Process {
    try {
      $conn.Connect($ComputerName, $PortNumber)
	
	  if ($conn.Connected) {
	    Write-Output "Open"
	  }
	}
	catch [System.Management.Automation.MethodInvocationException] {
	  Write-Output "Closed/Filtered"
	}
  }
  End {
    $conn.Close()
	$conn = $null
  }
}
} -ScriptBlock { param($hostlist)
   
  $MyCol = @()
  foreach ($line in $hostlist){
    $PhysicalServer = $line.PhysicalServer
    $VirtualServer   = $line.VirtualServer
    $ilo   = $line.ilo

    if ($PhysicalServer){$PhysicalRDP = Test-TCPPortConnection -ComputerName $PhysicalServer -Port 3389}
    else {$PhysicalServer = "";$PhysicalRDP = ""}
    
    if ($VirtualServer){$VirtualRDP = Test-TCPPortConnection -ComputerName $VirtualServer -Port 3389}
    else {$VirtualServer = "";$VirtualRDP = ""}
  
    if ($ilo){$IloValid = Test-Connection -ComputerName $ilo -Quiet -Count 4}
    else {$ilo = "";$ilovalid = ""}

    $hash = @{
     PhysicalServer = $PhysicalServer
     VirtualServer =  $VirtualServer
     PhysicalRDP = $PhysicalRDP
     VirtualRDP = $VirtualRDP
     iLOIpAddress = $ilo
     iLOValid = $ilovalid
    }
   $Object = New-Object PSObject -Property $hash
   $MyCol += $Object 
  }
  $MyCol
} -ArgumentList (,$hostlist)
    $j.name = "Script`:$totalJobCount`:$($i+1)`:$($HostList.count)"
    write-host "+" -back black -fore cyan -nonewline
  }

write-host "`n$totaljobCount jobs submitted, checking for completed jobs..." -back black -fore yellow


while (get-job |? {$_.name -like "Script*"}){
    foreach ($j in get-job | ? {$_.name -like "Script*"}){
        $temp = @()
        if ($j.state -eq "completed"){ 
            $temp = @()
            $temp += receive-job $j
            $result += $temp
            remove-job $j
            $ActiveJobCount -= 1
            write-host "-" -back black -fore cyan -nonewline
            }
           elseif ($j.state -eq "failed"){
            $temp = $j.name.split(":")
            if ($temp[1] -eq "R"){
                $temp = @()
                $temp += receive-job $j
                $result += $temp
                remove-job $j
                $ActiveJobCount -= 1
                write-host "-" -back black -fore cyan -nonewline
                }
            else{
                write-host "`nFailure detected in job: $($j.name)" -back black -fore red
                $temp = @()
                $temp += receive-job $j
                $result += $temp
                remove-job $j
                $ActiveJobCount -= 1
                }
            }
        }

 if ($result.count -lt $itemCount){
        sleep 3
        }
  }
write-host " "
write-host "Script finished at $(get-date -uFormat "%Y/%m/%d %H:%M:%S")".padright(60)             -back darkgreen -fore white
write-host ("   Elapsed Time : {0}" -f $($ElapsedTime.Elapsed.ToString())) -back black -fore green
$result | select PhysicalServer,PhysicalRDP,VirtualServer,VirtualRDP,iloipaddress,IloValid |sort physicalserver,virtualserver |ft -AutoSize
write-host  " Script completed all requested operations at $(get-date -uFormat "%Y/%m/%d %H:%M:%S")".padright(60) -back darkgreen -fore white
write-host ("   Elapsed Time : {0}" -f $($ElapsedTime.Elapsed.ToString())) -back black -fore green
$elapsedTime.Stop()


  • Marked as answer by Mekac 22 hours 47 minutes ago
Free Windows Admin Tool Kit Click here and download it now
July 27th, 2015 4:25am

Ive modified it for running via background jobs  (for faster results)

Param ([int]$BatchSize=2)
 #list of servers
$source = import-csv .\connsource.csv -Delimiter ";"

$elapsedTime = [system.diagnostics.stopwatch]::StartNew()
$result = @()
$itemCount = 0

## checking running jobs 
if (get-job|? {$_.name -like "Script*"}){
    write-host "ERROR: There are pending background jobs in this session:" -back red -fore white
    get-job |? {$_.name -like "Script*"} | out-host
    write-host "REQUIRED ACTION: Remove the jobs and restart this script" -back black -fore yellow
    $yn = read-host "Automatically remove jobs now?"
    if ($yn -eq "y"){
        get-job|? {$_.name -like "Script*"}|% {remove-job $_}
        write-host "jobs have been removed; please restart the script" -back black -fore green
        }
    exit
    }
$i = 0

$itemCount = $source.count
write-host "Script started at $(get-date -uFormat "%Y/%m/%d %H:%M:%S")".padright(60)             -back darkgreen -fore white
write-host "                    (contains $itemCount unique entries)" -back black -fore green
$activeJobCount = 0
$totalJobCount = 0
write-host "Submitting background jobs..." -back black -fore yellow
for ($i=0; $i -lt $itemCount;$i += $batchSize){
    $activeJobCount += 1; $totalJobCount += 1; $HostList = @()
    $HostList += $source |select -skip $i -first $batchsize
    $j = start-job -InitializationScript {
    function Test-TcpPortConnection {
  [CmdletBinding()]
  Param (
    [Parameter(Mandatory=$true)]
    [string] $ComputerName,
	[Parameter(Mandatory=$true)]
	[string]$PortNumber
  )
  Begin {
    $conn = New-Object Net.Sockets.TcpClient
  }
  Process {
    try {
      $conn.Connect($ComputerName, $PortNumber)
	
	  if ($conn.Connected) {
	    Write-Output "Open"
	  }
	}
	catch [System.Management.Automation.MethodInvocationException] {
	  Write-Output "Closed/Filtered"
	}
  }
  End {
    $conn.Close()
	$conn = $null
  }
}
} -ScriptBlock { param($hostlist)
   
  $MyCol = @()
  foreach ($line in $hostlist){
    $PhysicalServer = $line.PhysicalServer
    $VirtualServer   = $line.VirtualServer
    $ilo   = $line.ilo

    if ($PhysicalServer){$PhysicalRDP = Test-TCPPortConnection -ComputerName $PhysicalServer -Port 3389}
    else {$PhysicalServer = "";$PhysicalRDP = ""}
    
    if ($VirtualServer){$VirtualRDP = Test-TCPPortConnection -ComputerName $VirtualServer -Port 3389}
    else {$VirtualServer = "";$VirtualRDP = ""}
  
    if ($ilo){$IloValid = Test-Connection -ComputerName $ilo -Quiet -Count 4}
    else {$ilo = "";$ilovalid = ""}

    $hash = @{
     PhysicalServer = $PhysicalServer
     VirtualServer =  $VirtualServer
     PhysicalRDP = $PhysicalRDP
     VirtualRDP = $VirtualRDP
     iLOIpAddress = $ilo
     iLOValid = $ilovalid
    }
   $Object = New-Object PSObject -Property $hash
   $MyCol += $Object 
  }
  $MyCol
} -ArgumentList (,$hostlist)
    $j.name = "Script`:$totalJobCount`:$($i+1)`:$($HostList.count)"
    write-host "+" -back black -fore cyan -nonewline
  }

write-host "`n$totaljobCount jobs submitted, checking for completed jobs..." -back black -fore yellow


while (get-job |? {$_.name -like "Script*"}){
    foreach ($j in get-job | ? {$_.name -like "Script*"}){
        $temp = @()
        if ($j.state -eq "completed"){ 
            $temp = @()
            $temp += receive-job $j
            $result += $temp
            remove-job $j
            $ActiveJobCount -= 1
            write-host "-" -back black -fore cyan -nonewline
            }
           elseif ($j.state -eq "failed"){
            $temp = $j.name.split(":")
            if ($temp[1] -eq "R"){
                $temp = @()
                $temp += receive-job $j
                $result += $temp
                remove-job $j
                $ActiveJobCount -= 1
                write-host "-" -back black -fore cyan -nonewline
                }
            else{
                write-host "`nFailure detected in job: $($j.name)" -back black -fore red
                $temp = @()
                $temp += receive-job $j
                $result += $temp
                remove-job $j
                $ActiveJobCount -= 1
                }
            }
        }

 if ($result.count -lt $itemCount){
        sleep 3
        }
  }
write-host " "
write-host "Script finished at $(get-date -uFormat "%Y/%m/%d %H:%M:%S")".padright(60)             -back darkgreen -fore white
write-host ("   Elapsed Time : {0}" -f $($ElapsedTime.Elapsed.ToString())) -back black -fore green
$result | select PhysicalServer,PhysicalRDP,VirtualServer,VirtualRDP,iloipaddress,IloValid |sort physicalserver,virtualserver |ft -AutoSize
write-host  " Script completed all requested operations at $(get-date -uFormat "%Y/%m/%d %H:%M:%S")".padright(60) -back darkgreen -fore white
write-host ("   Elapsed Time : {0}" -f $($ElapsedTime.Elapsed.ToString())) -back black -fore green
$elapsedTime.Stop()


  • Marked as answer by Mekac Monday, July 27, 2015 8:24 AM
July 27th, 2015 8:23am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics