Hi All,
Good Day to all. Iam new to PowerShell (just started using it)...
Iam trying to install an application using powershell, but iam unable to get the status in text format (like installation successful or failed). Can you guys please help me, where i went wrong.
***************************************************************************
#Servers path
$ServerName = Get-content -path "C:\Users\Administrator\Servers.txt"
#netbackup sourcefile (Sample); Generally, The Source is taken from any other shared path
$sourcefile = "C:\Users\Administrator\Desktop\NB\NB_7.5.0.6.winnt.x64.Client.Win2012.exe"
#This section will install the software
foreach ($ComputerName in $Servername)
{
$destinationFolder = "D:\NB\Temp"
#This section will copy the $sourcefile to the $destinationfolder. If the Folder does not exist it will create it.
if (!(Test-Path -path $destinationFolder))
{
New-Item $destinationFolder -Type Directory
}
Copy-Item -Path $sourcefile -Destination $destinationFolder
# Install NetBackup Client
Invoke-Command -ComputerName $ComputerName -ScriptBlock {Start-Process 'C:\temp\NB_7.5.0.6.winnt.x64.Client.Win2012.exe' -ArgumentList "/s" -Wait}
if ($setup.exitcode -eq 0) {
write-host "Successfully installed"
}
else
{
Write-Host "Installation Failed"
}
#Output the install result to your Local D Drive
Out-File -FilePath D:\NB\NB.txt -Append -InputObject "$computer"
}
************************************************************************************