Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion MAKE.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ $PackageFilePatternExclusions = @(

$here = Split-Path -Parent $MyInvocation.MyCommand.Path

$Version = "0.1.2"
$Version = "0.1.5"
$ModuleName = "PSServiceNow"
$PackageName = "$ModuleName-v$($version).zip";

Expand Down
63 changes: 5 additions & 58 deletions PSServiceNow-Tables.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ function New-ServiceNowTableEntry{
Untested
#>
function Remove-ServiceNowTableEntry{
[CmdletBinding(ConfirmImpact='High')]
[CmdletBinding(ConfirmImpact='High')]
Param(
# sys_id of the entry we're deleting
[parameter(mandatory=$true)]
Expand Down Expand Up @@ -191,58 +191,7 @@ function Remove-ServiceNowTableEntry{
$Connection
)

#Get credential and ServiceNow REST URL
if ($Connection -ne $null)
{
$ConnectionInfo = Get-ConnectionInfo -Connection $Connection
}
elseif ($ServiceNowCredential -ne $null -and $ServiceNowURL -ne $null)
{
$ConnectionInfo = Get-ConnectionInfo -ServiceNowCredential $ServiceNowCredential -ServiceNowURL $ServiceNowURL
}
else
{
$ConnectionInfo = Get-ConnectionInfo -UseGlobalAuth $true
}


# Fire and return
$Uri = $ConnectionInfo["URL"] + "/table/$Table/$SysID"
return (Invoke-RestMethod -Uri $uri -Method Delete -Credential $ConnectionInfo["Credential"] -Body $Body -ContentType "application/json" -UseBasicParsing).result
}


function Get-ConnectionInfo
{
[OutputType([HashTable])]
param (
# Credential used to authenticate to ServiceNow
[Parameter(ParameterSetName='SpecifyConnectionFields', Mandatory=$True)]
[ValidateNotNullOrEmpty()]
[PSCredential]
$ServiceNowCredential,

# The URL for the ServiceNow instance being used
[Parameter(ParameterSetName='SpecifyConnectionFields', Mandatory=$True)]
[ValidateNotNullOrEmpty()]
[string]
$ServiceNowURL,

#Azure Automation Connection object containing username, password, and URL for the ServiceNow instance
[Parameter(ParameterSetName='UseConnectionObject', Mandatory=$True)]
[ValidateNotNullOrEmpty()]
[Hashtable]
$Connection,

[Parameter(ParameterSetName='SetGlobalAuth', Mandatory=$True)]
[ValidateNotNullOrEmpty()]
[Bool]
$UseGlobalAuth

)


#Get credential and ServiceNow REST URL
#Get credential and ServiceNow REST URL
if ($Connection -ne $null)
{
$SecurePassword = ConvertTo-SecureString $Connection.Password -AsPlainText -Force
Expand All @@ -264,9 +213,7 @@ function Get-ConnectionInfo
throw "Exception: You must do one of the following to authenticate: `n 1. Call the Set-ServiceNowAuth cmdlet `n 2. Pass in an Azure Automation connection object `n 3. Pass in an endpoint and credential"
}

$Connectioninfo = @{}
$ConnectionInfo.Add("Credential", $ServiceNowCredential)
$Connectioninfo.Add("URL", $ServiceNowURL)

return $Connectioninfo
# Fire and return
$Uri = $ServiceNowURL + "/table/$Table/$SysID"
return (Invoke-RestMethod -Uri $uri -Method Delete -Credential $ServiceNowCredential -Body $Body -ContentType "application/json").result
}
4 changes: 2 additions & 2 deletions PSServiceNow-Users.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function Get-ServiceNowUserGroup{

# Set the default property set for the table view
$DefaultProperties = @('name', 'email', 'sys_id')
$DefaultDisplayPropertySet = New-Object System.Management.Automation.PSPropertySet(DefaultDisplayPropertySet,[string[]]$DefaultProperties)
$DefaultDisplayPropertySet = New-Object System.Management.Automation.PSPropertySet('DefaultDisplayPropertySet',[string[]]$DefaultProperties)
$PSStandardMembers = [System.Management.Automation.PSMemberInfo[]]@($DefaultDisplayPropertySet)
$Result | Add-Member MemberSet PSStandardMembers $PSStandardMembers
return $result
Expand Down Expand Up @@ -181,7 +181,7 @@ function Get-ServiceNowUser{

# Set the default property set for the table view
$DefaultProperties = @('name', 'email', 'sys_id')
$DefaultDisplayPropertySet = New-Object System.Management.Automation.PSPropertySet(DefaultDisplayPropertySet,[string[]]$DefaultProperties)
$DefaultDisplayPropertySet = New-Object System.Management.Automation.PSPropertySet('DefaultDisplayPropertySet',[string[]]$DefaultProperties)
$PSStandardMembers = [System.Management.Automation.PSMemberInfo[]]@($DefaultDisplayPropertySet)
$Result | Add-Member MemberSet PSStandardMembers $PSStandardMembers
return $result
Expand Down
2 changes: 1 addition & 1 deletion PSServiceNow.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'PSServiceNow.psm1'

# Version number of this module.
ModuleVersion = '0.1.4'
ModuleVersion = '0.1.5'

# ID used to uniquely identify this module
GUID = 'b90d67da-f8d0-4406-ad74-89d169cd0633'
Expand Down
2 changes: 1 addition & 1 deletion Readme.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# PSServiceNow
[![GitHub release](https://img.shields.io/github/release/Sam-Martin/servicenow-powershell.svg)](https://github.com/Sam-Martin/servicenow-powershell/releases/latest) [![GitHub license](https://img.shields.io/github/license/Sam-Martin/servicenow-powershell.svg)](LICENSE) ![Test Coverage](https://img.shields.io/badge/coverage-87%25-yellowgreen.svg)
[![GitHub release](https://img.shields.io/github/release/Sam-Martin/servicenow-powershell.svg)](https://github.com/Sam-Martin/servicenow-powershell/releases/latest) [![GitHub license](https://img.shields.io/github/license/Sam-Martin/servicenow-powershell.svg)](LICENSE) ![Test Coverage](https://img.shields.io/badge/coverage-70%25-yellowgreen.svg)
This PowerShell module provides a series of cmdlets for interacting with the [ServiceNow REST API](http://wiki.servicenow.com/index.php?title=REST_API), performed by wrapping `Invoke-RestMethod` for the API calls.
**IMPORTANT:** Neither this module, nor its creator are in any way affiliated with ServiceNow.

Expand Down