Skip to content

Allow login with Username and Password #88

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 44 additions & 22 deletions Veeam/PRTG-VeeamBRStats.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,13 @@ param(
[Parameter(Position=3, Mandatory=$false)]
$repoWarn = 20,
[Parameter(Position=4, Mandatory=$false)]
$selChann = "BCRE", # Inital channel selection
[string]$selChann = "BCRE", # Inital channel selection
[Parameter(Position=5, Mandatory=$false)]
[switch] $PSRemote
[switch] $PSRemote,
[Parameter(Position=6, Mandatory=$false)]
[string] $User = "", #contoso\monitoring (better to run the Script as different User over task scheduler)
[Parameter(Position=7, Mandatory=$false)]
[string] $Password = ""
)

$includeBackup = $selChann.Contains("B")
Expand Down Expand Up @@ -311,33 +315,51 @@ Function Get-vPCRepoInfoPre11 {
#region: Start BRHost Connection
Write-Debug "Starting to Process Connection to '$BRHost' with user '$env:USERNAME' ..."
$OpenConnection = (Get-VBRServerSession).Server
if($OpenConnection -eq $BRHost) {

if($OpenConnection -eq $BRHost)
{
Write-Debug "BRHost '$BRHost' is Already Connected..."
} elseif ($null -eq $OpenConnection) {
Write-Debug "Connecting BRHost '$BRHost' with user '$env:USERNAME'..."
try {
Connect-VBRServer -Server $BRHost
}
catch {
Throw "Failed to connect to Veeam BR Host '$BRHost' with user '$env:USERNAME'"
}
} else {
Write-Debug "Disconnection current BRHost..."
Disconnect-VBRServer
}

else
{
if($OpenConnectionn)
{
Write-Debug "Disconnection current BRHost..."
Disconnect-VBRServer
}

Write-Debug "Connecting new BRHost '$BRHost' with user '$env:USERNAME'..."

try {
Connect-VBRServer -Server $BRHost
}
catch {
Throw "Failed to connect to Veeam BR Host '$BRHost' with user '$env:USERNAME'"
}
}
if(($User -ne "") -and ($Password -ne ""))
{
Connect-VBRServer -Server $BRHost -User $User -Password $Password
}
else
{
Connect-VBRServer -Server $BRHost
}
}
catch
{
if(($User -ne "") -and ($Password -ne ""))
{
Throw "Failed to connect to Veeam BR Host '$BRHost' with specified User($($User)) and Password"
}
else
{
Throw "Failed to connect to Veeam BR Host '$BRHost' with user '$env:USERNAME'"
}
}
}


$NewConnection = (Get-VBRServerSession).Server
if ($null -eq $NewConnection) {
if ($null -eq $NewConnection)
{
Throw "Failed to connect to Veeam BR Host '$BRHost' with user '$env:USERNAME'"
}
}
#endregion

#region: Convert mode (timeframe) to hours
Expand Down