tpcarman / As-Built-Report

A collection of PowerShell scripts to generate as built reports on the configuration of datacentre infrastucture in Text, XML, HTML & MS Word formats.
MIT License
88 stars 28 forks source link

Refactor project as PowerShell Module #30

Closed ryan-jan closed 6 years ago

ryan-jan commented 6 years ago

Description

This change addresses the initial phase of #25 in that it converts the New-AsBuiltReport.ps1 into an advanced function and refactors the project into a module. I have also updated the New-AsBuiltReport.ps1 help contents and the main project README.md to reflect this change.

Related Issue

25

Motivation and Context

This change has been discussed with the team and is generally accepted as the correct way forward. It allows us to provide the standardised PowerShell command style that users are used to using. It also allows us to start investigating hosting the project on the PSGallery for easier installation.

How Has This Been Tested?

Functionality

I have tested this re factored module against my test environments and no issues were found when generating multiple reports.

PSGallery Compatability

I have tested this module's ability to be hosted on PSGallery by creating a local PSGallery repository, publishing this module to my local repo and then installing it from my local repo. The steps I used are as follows.

NOTE - you must have installed PScribo from the official PSGallery repository to be able to follow these steps.

  1. Create a local PSGallery repo on you machine.
    • mkdir C:\LocalPSRepo
    • Register-PSRepository -Name LocalPSRepo -SourceLocation C:\LocalPSRepo -PublishLocation C:\LocalPSRepo -InstallationPolicy Trusted
  2. Temporarily add the parent directory of your cloned repository to $env:PSModulePath
    • If your cloned repository is C:\Users\Ryan\Stuff\As-Built-Report you would run the following command.
    • $env:PSModulePath += ";C:\Users\Ryan\Stuff\"
  3. Now we need to publish the PScribo module to our local PSGallery repository. This is because we have listed PScribo as a dependency to our module.
    • Publish-Module -Name PScribo -Repository LocalPSRepo -Verbose
  4. Now we can publish our module to our local PSGallery repository.
    • Publish-Module -Name As-Built-Report -Repository LocalPSRepo -Verbose
    • We can now see both PScribo and As-Built-Report modules listed in our LocalPSRepo when we run Find-Module -Repository LocalPSRepo
  5. Finally we can install the As-Built-Report module from our LocalPSRepo. Close your current PowerShell session and start a new one. Now run the following command.
    • Install-Module As-Built-Report -Scope CurrentUser
      1. You can now import the As-Built-Report module like any other module.
    • Import-Module As-Built-Report
    • Get-Command -Module As-Built-Report

Types of changes

Checklist: