JAMS 6.x Help
The JAMS PowerShell Provider

Introduction to Windows PowerShell Providers

A Windows PowerShell provider is a .NET program that allows any data store to be viewed as if it were a mounted drive. The data, which appears in a temporary drive for the session, can be managed with built-in or custom cmdlets.

A provider can also override the "Item" cmdlets (for example, “Get-Item”, “Set-Item”, etc.) in ways that allow the data store data to be treated like typical files and directories in a file system.

Each Windows PowerShell provider exposes a drive called a PSDrive. The PSDrive is then used to display the data that is exposed via the Windows PowerShell provider. So, by default, you can gain access to the Alias, Environment, FileSystem, Function, Registry, and Variable providers.

Using PowerShell Providers with JAMS

You can use the PowerShell and the JAMS PowerShell provider drive capabilities to synchronize Jobs and Setups, between JAMS Servers. A JAMS PowerShell provider drive allows you to access the JAMS SQL Database backend as if it were a flat file system.

To add a new PowerShell drive, open a PowerShell window (running as an Administrator), and type the following information at the PowerShell prompt:

Adding a PowerShell Drive
Copy Code
New-PSDrive MyDrv JAMS your.server.name

Where "MyDrv" is your specification for the new "drive letter/phrase" and "your.server.name" is the name of the server where you want to create the temporary drive.

Once you have a drive added for the servers, you can change the directory to that drive and run a simple "dir" commands to drill down through the file structure of each server. For example, if you wish to view all Jobs on a server, enter the following:

Viewing all Job on a Server
Copy Code
PS C:\temp> cd JD:\ PS JD:> cd Folder/Samples/

This will go into the Systems directory, then into the Samples System, and finally into the Jobs directory for that System. You can then perform all of the same commands as you would on any flat file system to copy or move any portion of JAMS information from one server to another or to a different name on the same server.

 For additional ways to work with the provider, review the examples below.

Example: Copying a Job between Servers

Copying a Job between Servers
Copy Code

Import-Module JAMS

#

# Create a new JAMS Drive for two JAMS servers

#

New-PSDrive -Name JD -PSProvider JAMS -Root localhost

New-PSDrive -Name JDServerB -PSProvider JAMS -Root ServerB

# Move into the Samples Folder

Set-Location JD:\Samples\

#

# Copy the Sleep60 Job to another JAMS server

#

Copy-Item -Path JD:\Samples\Sleep120 -Destination JDServerB:\Test\ -Verbose

Example: Creating a Variable

Creating a Variable
Copy Code

Import-Module JAMS

#

# Create a new JAMS Drive for the local primary engine

#

New-PSDrive -Name JD -PSProvider JAMS -Root localhost

# Move into the Samples Folder

Set-Location JD:\Samples\

#

# Create a new Variable in the Samples Folder

#

$newVar = New-Item -ItemType Variable -Name DBName

$newVar.Description = "The name of the test database."

$newVar.DataType = [MVPSI.JAMS.DataType]::Text

$newVar.Value = "BusinessTestingDB";

$newVar.Update();

Example: Updating Job Properties

Updating Job Properties
Copy Code

Import-Module JAMS

#

# Create a new JAMS Drive for the local primary engine

#

New-PSDrive -Name JD -PSProvider JAMS -Root localhost

# Move into the Samples Folder

Set-Location JD:\Samples\

# Get the Sleep 120 Job

$job = Get-ChildItem *Sleep120*

if($job)

{

    #

    # Update properties on the Job

    #

    $job.JobName = "Sleep500"

    $job.Source = "Start-Sleep 500"

    $job.Description = "Sleeps for 500 seconds";

    $job.Update();

}

See Also

 

 


Topic updated: 7/14/2015
©2017 MVP Systems Software, Inc. All Rights Reserved.

Send comments on this topic.