troubleshooting Question

IF statment In Powershell

Avatar of Suresh Kumar
Suresh Kumar asked on
PowershellHTML* if statements
12 Comments1 Solution102 ViewsLast Modified:
    [string]$ComputerName = $env:ComputerName
$Head = @'
TABLE      {border-width:1px; border-style:solid; border-color:black; border-collapse:collapse;}
TH            {border-width:1px; padding:2px; border-style:solid; border-color:black;}
TD            {border-width:1px; padding:2px; border-style:solid; border-color:black;}

$Body = @'
<H2>Status for {0}</H2>
'@ -f $ComputerName

$Status = @()
$Stuff = @()
Invoke-Command -ComputerName $ComputerName -ScriptBlock {& opcagt -version} | ForEach-Object {
            $Stuff += $_
($Status | ConvertTo-Html -Head $Head -Body $Body -PostContent "<br /> $($Stuff -join '<br />')") -replace '^<html.*$', "<html>" | Out-file -Filepath C:\tmp\ver.txt
Get-Content 'C:\tmp\ver.txt' | Set-Content 'C:\tmp\ver1.txt'
cat C:\tmp\ver1.txt

The above script gives the ouput of the HPOV ( HP Openview )Version

I need to add a if statement to check if  HPOV installed,If installed it need to run the script  else need to say ÖV not installed on the Server in HTML format

i.e.I need to check if OvInstallDir is there  in the server if so then need to run the script else come out of the script saying "OV not installed on the server" in the HTML format

OvInstallDir=C:\Program Files\HP\HP BTO Software\

Can you help me on this?
Join our community to see this answer!
Unlock 1 Answer and 12 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 12 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros