This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Best way to Connect to QARS Service? in PowerShell (As quickly as possible)

Hi, 

I'm frustrated by how long it can take to get a usable QARS connection established in my scripts.

The code I have mostly used is:

## Load QARS Module
if ( (Get-PSSnapin -Name Quest.ActiveRoles.ADManagement -ErrorAction SilentlyContinue) -eq $null )
{
  Write-Host "Adding Quest ActiveRoles Module" -foregroundcolor Blue
  Add-PSSnapin Quest.ActiveRoles.ADManagement
}

## Connect to QARS
Write-Host "Attempting to connecting to QADService" -foregroundcolor Blue
try { $connectAttempt = Connect-QADService -proxy }
catch { Write-Host "Connection attempted errored - Please try rerunning script" -ForegroundColor Red
        exit
}
finally { 
    Write-Host "Value of `$connectAttempt is $connectAttempt"
    if ("$connectAttempt" -match "Quest.ActiveRoles.ArsPowerShellSnapIn.Data.ArsServerConnection") {
        Write-Host "Connection attempt appears to have been successful`n" -ForegroundColor DarkGreen
    }
 }

This works, but loading the Snapin takes quite a while.  Whilst searching for a faster way I learned that the Get-PSSnapin syntax is deprecated.  So I have been attempting to load the module using:

Set-Location "C:\Program Files\Quest Software\Management Shell for AD"
Import-Module .\Quest.ActiveRoles.ArsPowerShellSnapIn.dll

This seems much quicker - However when I then attempt to connect to QARS (using same code as in first snippet) the connection can take a long time to establish.

I have failed to find any useful documentation on this - I am happy to read anything people can link me to? 

Alternatively, could anyone share their experiences and or chosen way to manage the load of the module and connect to the service.  I'd really like to find the fastest method I can for this, to include in frequently run scripts.

Thanks in advance,

Andrew

PS Should probably have said the environment I am in uses 6.9.0 I believe (based on install files I used)

Parents
  • Thank you very much for your response.

    It is useful to know that my code is valid and can run quickly.

    To clarify - I am interested in the total time from the start of running a script, to being connected. So as I understand it I need to load the snapin\module _and_ then connect. With that in mind...

    Running: Import-Module .\Quest.ActiveRoles.ArsPowerShellSnapIn.dll takes <1 second
    Running: Add-PSSnapin Quest.ActiveRoles.ADManagement takes ~35 seconds

    So looking only at that, I think the choice of which to use would be clear. However what I thought I was observing the other day was that the first command (e.g. Get-QADUser) run after loading and connecting would run in a reasonable time if I had used the Add-PSSnapin, but take a much longer if I had used the Import-Module command. The amount of time felt like it might be approximately as long as the Add-PSSnapin had taken to run. This lead me to wonder whether the module actually only *really* got loaded when the first command that needed to use it was run.

    I have just run some basic tests and Load, Connect & Query for:
    Import-Module ~10 seconds
    Add-PSSnapin ~40 seconds

    That ~10 second result is much faster than I was experiencing the other day, when I was prompted to make my original post.

    In terms of pure connection times, my collected stats over the last 24 hours against the eight version 6.x servers range from 2.08s to 5.31s. Of the eight, two are web something or others.

    I am afraid I don't have local access to the ActiveRoles Server hosts to be able to test performance of Load, Connect & Query on them. Nor do I have sufficient remote access to see what local resources they have. The server I typically use to query from is a VM, 2008R2 4x Xenon E5-2680 @2700MHz & 48Gb RAM. I don't know what kind of contention I might be suffering. It is driven hard with all CPUs typically at 100%. That said it is normally responsive enough to work on. I am just looking for the best way to use what I have.
Reply
  • Thank you very much for your response.

    It is useful to know that my code is valid and can run quickly.

    To clarify - I am interested in the total time from the start of running a script, to being connected. So as I understand it I need to load the snapin\module _and_ then connect. With that in mind...

    Running: Import-Module .\Quest.ActiveRoles.ArsPowerShellSnapIn.dll takes <1 second
    Running: Add-PSSnapin Quest.ActiveRoles.ADManagement takes ~35 seconds

    So looking only at that, I think the choice of which to use would be clear. However what I thought I was observing the other day was that the first command (e.g. Get-QADUser) run after loading and connecting would run in a reasonable time if I had used the Add-PSSnapin, but take a much longer if I had used the Import-Module command. The amount of time felt like it might be approximately as long as the Add-PSSnapin had taken to run. This lead me to wonder whether the module actually only *really* got loaded when the first command that needed to use it was run.

    I have just run some basic tests and Load, Connect & Query for:
    Import-Module ~10 seconds
    Add-PSSnapin ~40 seconds

    That ~10 second result is much faster than I was experiencing the other day, when I was prompted to make my original post.

    In terms of pure connection times, my collected stats over the last 24 hours against the eight version 6.x servers range from 2.08s to 5.31s. Of the eight, two are web something or others.

    I am afraid I don't have local access to the ActiveRoles Server hosts to be able to test performance of Load, Connect & Query on them. Nor do I have sufficient remote access to see what local resources they have. The server I typically use to query from is a VM, 2008R2 4x Xenon E5-2680 @2700MHz & 48Gb RAM. I don't know what kind of contention I might be suffering. It is driven hard with all CPUs typically at 100%. That said it is normally responsive enough to work on. I am just looking for the best way to use what I have.
Children
No Data