Skip to content

Commit ddc1cf0

Browse files
committed
Renamed module to PSServiceNow from ServiceNow-Module
1 parent 3096b09 commit ddc1cf0

11 files changed

+185
-8
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
ServiceNow-Module.Pester.Defaults.json
2+
*.zip
3+
PSServiceNow.Pester.Defaults.json

MAKE.ps1

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
function ZipFiles
2+
{
3+
param( $zipfilename, $sourcedir )
4+
Add-Type -Assembly System.IO.Compression.FileSystem
5+
$compressionLevel = [System.IO.Compression.CompressionLevel]::Optimal
6+
[System.IO.Compression.ZipFile]::CreateFromDirectory($sourcedir,
7+
$zipfilename, $compressionLevel, $true)
8+
}
9+
10+
function New-MakePackage{
11+
param(
12+
[string[]]$PackageFilePatternExclusions,
13+
[string]$PackageName,
14+
[string]$ModuleName
15+
)
16+
($FilePatternExclusions | %{"MAKE.zip" -match $_}).contains($true)
17+
18+
$FilesToInclude = Get-ChildItem -Path $here | ?{
19+
$File=$_;
20+
!$_.PSIsContainer -and
21+
!($PackageFilePatternExclusions | %{$File.Name -match $_}).contains($true)
22+
}
23+
24+
# Create temporary folder and copy the files we want into it
25+
New-Item $here\$ModuleName -ItemType Container -Force | Out-Null
26+
$FilesToInclude | %{Copy-Item -Path $_.FullName -Destination $here\$ModuleName\$_ -Force}
27+
28+
# Create a zip based on that folder (overwriting it if it already exists)
29+
$ZipFile = "$here\$PackageName"
30+
Remove-Item $ZipFile -Force -ErrorAction SilentlyContinue | Out-Null
31+
ZipFiles $ZipFile $here\$ModuleName
32+
Remove-Item $here\$ModuleName -Recurse| Out-Null
33+
}
34+
35+
Function Update-CodeCoveragePercent{
36+
param(
37+
[int]$CodeCoverage=0,
38+
[string]$TextFilePath="$here\Readme.md"
39+
)
40+
$ReadmeContent = Get-Content $TextFilePath
41+
$ReadmeContent = $ReadmeContent | %{$_-replace "!\[Test Coverage\].+\)", "![Test Coverage](https://img.shields.io/badge/coverage-$CodeCoverage%25-yellowgreen.svg)"}
42+
Set-Content -Path $TextFilePath -Value $ReadmeContent
43+
}
44+
45+
Function UpdateManifest{
46+
param(
47+
[string]$ManifestPath,
48+
[string]$Version
49+
)
50+
51+
Write-Verbose "Updating $ManifestPath to version $Version"
52+
$ManifestContent = Get-Content $ManifestPath
53+
$ManifestContent = $ManifestContent | %{$_ -replace "ModuleVersion = '(\d|\.)+'", "ModuleVersion = '$Version'"}
54+
Set-Content -path $ManifestPath -Value $ManifestContent
55+
}
56+
57+
$PackageFilePatternExclusions = @(
58+
"MAKE\.ps1",
59+
".+\.zip",
60+
".+\.md"
61+
".+\.Tests\.ps1",
62+
"\.gitignore",
63+
"LICENSE",
64+
".+\.Pester.Defaults.json"
65+
)
66+
67+
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
68+
69+
$Version = "0.1.1"
70+
$ModuleName = "PSServiceNow"
71+
$PackageName = "$ModuleName-v$($version).zip";
72+
73+
# Perform Pester tests
74+
$TestResult = Invoke-Pester -CodeCoverage '*.psm1' -PassThru
75+
$CoveragePercent = 100-(($testResult.CodeCoverage.NumberOfCommandsMissed/$testResult.CodeCoverage.NumberOfCommandsAnalyzed)*100)
76+
77+
# Update/Create the package and
78+
if($TestResult.FailedCount -eq 0){
79+
New-MakePackage -PackageFilePatternExclusions $PackageFilePatternExclusions -PackageName $PackageName -ModuleName $ModuleName
80+
Update-CodeCoveragePercent -CodeCoverage $CoveragePercent
81+
UpdateManifest -ManifestPath "$here\$ModuleName.psd1" -Version $Version
82+
}
83+
File renamed without changes.
File renamed without changes.
File renamed without changes.

ServiceNow-Module.Tests.ps1 renamed to PSServiceNow.Tests.ps1

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
2-
$DefaultsFile = "$here\ServiceNow-Module.Pester.Defaults.json"
2+
$DefaultsFile = "$here\PSServiceNow.Pester.Defaults.json"
33

44
# Load defaults from file (merging into $global:ServiceNowPesterTestDefaults
55
if(Test-Path $DefaultsFile){
@@ -23,8 +23,8 @@ if(Test-Path $DefaultsFile){
2323
}
2424

2525
# Load the module (unload it first in case we've made changes since loading it previously)
26-
Remove-Module ServiceNow-Module -ErrorAction SilentlyContinue
27-
Import-Module $here\ServiceNow-Module.psd1
26+
Remove-Module PSServiceNow -ErrorAction SilentlyContinue
27+
Import-Module $here\PSServiceNow.psd1
2828

2929
Describe "ServiceNow-Module" {
3030

PSServiceNow.psd1

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#
2+
# Module manifest for module 'PSServiceNow'
3+
#
4+
# Generated by: Sam Martin
5+
#
6+
# Generated on: 03/05/2015
7+
#
8+
9+
@{
10+
11+
# Script module or binary module file associated with this manifest.
12+
RootModule = 'PSServiceNow.psm1'
13+
14+
# Version number of this module.
15+
ModuleVersion = '0.1.1'
16+
17+
# ID used to uniquely identify this module
18+
GUID = 'b90d67da-f8d0-4406-ad74-89d169cd0633'
19+
20+
# Author of this module
21+
Author = 'Sam Martin'
22+
23+
# Company or vendor of this module
24+
CompanyName = 'None'
25+
26+
# Copyright statement for this module
27+
Copyright = '(c) 2015 Sam. All rights reserved.'
28+
29+
# Description of the functionality provided by this module
30+
# Description = 'This module provides cmdlets allowing you to retrieve information from your ServiceNow instance`s rest API'
31+
32+
# Minimum version of the Windows PowerShell engine required by this module
33+
# PowerShellVersion = '3.0'
34+
35+
# Name of the Windows PowerShell host required by this module
36+
# PowerShellHostName = ''
37+
38+
# Minimum version of the Windows PowerShell host required by this module
39+
# PowerShellHostVersion = ''
40+
41+
# Minimum version of Microsoft .NET Framework required by this module
42+
# DotNetFrameworkVersion = ''
43+
44+
# Minimum version of the common language runtime (CLR) required by this module
45+
# CLRVersion = ''
46+
47+
# Processor architecture (None, X86, Amd64) required by this module
48+
# ProcessorArchitecture = 'None'
49+
50+
# Modules that must be imported into the global environment prior to importing this module
51+
# RequiredModules = @()
52+
53+
# Assemblies that must be loaded prior to importing this module
54+
# RequiredAssemblies = @()
55+
56+
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
57+
# ScriptsToProcess = @()
58+
59+
# Type files (.ps1xml) to be loaded when importing this module
60+
# TypesToProcess = @()
61+
62+
# Format files (.ps1xml) to be loaded when importing this module
63+
# FormatsToProcess = @()
64+
65+
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
66+
NestedModules = @(
67+
'PSServiceNow-Tables.psm1',
68+
'PSServiceNow-Incidents.psm1',
69+
'PSServiceNow-Users.psm1',
70+
'PSServiceNow-ConfigurationManagement.psm1'
71+
)
72+
73+
# Functions to export from this module
74+
FunctionsToExport = '*'
75+
76+
# List of all modules packaged with this module
77+
# ModuleList = @()
78+
79+
# List of all files packaged with this module
80+
# FileList = @()
81+
82+
# Private data to pass to the module specified in RootModule/ModuleToProcess
83+
# PrivateData = ''
84+
85+
# HelpInfo URI of this module
86+
# HelpInfoURI = 'https://github.com/Toukakoukan/servicenow-powershell'
87+
88+
# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
89+
# DefaultCommandPrefix = ''
90+
91+
}
92+
File renamed without changes.

Readme.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# servicenow-powershell
2-
[![GitHub release](https://img.shields.io/github/release/Toukakoukan/servicenow-powershell.svg)](releases/latest) [![GitHub license](https://img.shields.io/github/license/Toukakoukan/servicenow-powershell.svg)](blob/master/LICENSE) ![Test Coverage](https://img.shields.io/badge/test%20coverage-86%25-yellowgreen.svg)
1+
# PSServiceNow
2+
[![GitHub release](https://img.shields.io/github/release/Toukakoukan/servicenow-powershell.svg)](releases/latest) [![GitHub license](https://img.shields.io/github/license/Toukakoukan/servicenow-powershell.svg)](blob/master/LICENSE) ![Test Coverage](https://img.shields.io/badge/coverage-86%25-yellowgreen.svg)
33
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.
44
**IMPORTANT:** Neither this module, nor its creator are in any way affiliated with ServiceNow.
55

@@ -8,12 +8,12 @@ Requires PowerShell 3.0 or above as this is when `Invoke-RestMethod` was introdu
88

99
## Usage
1010
Download the [latest release](releases/latest) and extract the .psm1 and .psd1 files to your PowerShell profile directory (i.e. the `Modules` directory under wherever `$profile` points to in your PS console) and run:
11-
`Import-Module ServiceNow-Module`
12-
Once you've done this, all the cmdlets will be at your disposal, you can see a full list using `Get-Command -Module ServiceNow-Module`.
11+
`Import-Module PSServiceNow`
12+
Once you've done this, all the cmdlets will be at your disposal, you can see a full list using `Get-Command -Module PSServiceNow`.
1313

1414
### Example - Retrieving an Incident Containing the Word 'PowerShell'
1515
```
16-
Import-Module ServiceNow-Module
16+
Import-Module PSServiceNow
1717
Set-ServiceNowAuth
1818
Get-ServiceNowIncident -MatchContains @{short_description='PowerShell'}
1919
```

ServiceNow-Module.psd1

-5.32 KB
Binary file not shown.

0 commit comments

Comments
 (0)