Last active
February 22, 2020 13:18
-
-
Save SQLDBAWithABeard/6f911ae171528181d226a11e9a24ad05 to your computer and use it in GitHub Desktop.
Pester wont run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# Pester won't install in a .NET Notebook\n", | |
"\n", | |
"This notebook shows what happens when you try to run Pester in a .NET Notebook\n" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<pre>Describe: \r\n", | |
"Line |\r\n", | |
" 3 | Describe "Checking Problem ...... by $($ENV:USERDOMAIN) $($ENV:UserName)" {\r\n", | |
"\r\n", | |
" | ^ The 'Describe' command was found in the module 'Pester', but the module could not be loaded. For more information, run 'Import-Module Pester'.</pre>\r\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"## <----- Press this button - DONT MAKE A BEARD MAD BY CHANGING ANYTHING below here\n", | |
"\n", | |
"Describe \"Checking Problem ...... by $($ENV:USERDOMAIN) $($ENV:UserName)\" {\n", | |
" Context \" Are all the services running ?\" {\n", | |
" $Services = 'Audiosrv','BITS','com.docker.service','EventLog','MSSQLSERVER', 'Spooler'\n", | |
" foreach($Service in $Services){\n", | |
" It \"The Service $Service should be running\" {\n", | |
" (Get-Service -ComputerName localhost -Name $Service).Status | Should -Be 'Running' -Because \"Service XXXX requires the service $Service to be running\"\n", | |
" }\n", | |
" }\n", | |
" }\n", | |
"}" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"OK, lets try to import the Pester Module" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<pre>Get-Command: C:\\Users\\mrrob\\Documents\\PowerShell\\Modules\\Pester\\4.9.0\\Pester.psm1\r\n", | |
"Line |\r\n", | |
" 94 | $script:SafeCommands['Get-CimInstance'] = Get-Command -Name Get-CimInstance -Module CimCmdlets @safeCommandLookupParameters\r\n", | |
"\r\n", | |
" | ^ The term 'Get-CimInstance' is not recognized as the name of a\r\n", | |
" | cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included,\r\n", | |
" | verify that the path is correct and try again.</pre>\r\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre>Import-Module: The module to process 'Pester.psm1', listed in field 'ModuleToProcess/RootModule' of module manifest 'C:\\Users\\mrrob\\Documents\\PowerShell\\Modules\\Pester\\4.9.0\\Pester.psd1' was not processed because no valid module was found in any module directory.</pre>\r\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"Import-Module Pester" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"The module CimCmdlets is not available to the session" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"Get-MOdule CimCmdlets -ListAvailable" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"You can import it from the local PowerShell 7 installation" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"IPMO 'C:\\program files\\powershell\\7-preview\\Modules\\CimCmdlets\\CimCmdlets.psd1'" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"and now Pester will import without errors" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"ipmo Pester" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"and we can run a Pester Test :-)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 7, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<pre></pre>\r\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre>Describing Checking Problem ...... by BEARDXPS mrrob</pre>\r\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre></pre>\r\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> Context Are all the services running ?</pre>\r\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> [+] The Service Audiosrv should be running</pre>\r\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> 88ms</pre>\r\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> [-] The Service BITS should be running</pre>\r\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> 24ms</pre>\r\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> Expected 'Running', because Service XXXX requires the service BITS to be running, but got Stopped.</pre>\r\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> 6: (Get-Service -Name $Service).Status | Should -Be 'Running' -Because "Service XXXX requires the service $Service to be running"</pre>\r\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> [+] The Service com.docker.service should be running</pre>\r\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> 3ms</pre>\r\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> [+] The Service EventLog should be running</pre>\r\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> 4ms</pre>\r\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> [-] The Service MSSQLSERVER should be running</pre>\r\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> 7ms</pre>\r\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> Expected 'Running', because Service XXXX requires the service MSSQLSERVER to be running, but got Stopped.</pre>\r\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> 6: (Get-Service -Name $Service).Status | Should -Be 'Running' -Because "Service XXXX requires the service $Service to be running"</pre>\r\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> [+] The Service Spooler should be running</pre>\r\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<pre> 4ms</pre>\r\n" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"Describe \"Checking Problem ...... by $($ENV:USERDOMAIN) $($ENV:UserName)\" {\n", | |
" Context \" Are all the services running ?\" {\n", | |
" $Services = 'Audiosrv','BITS','com.docker.service','EventLog','MSSQLSERVER', 'Spooler'\n", | |
" foreach($Service in $Services){\n", | |
" It \"The Service $Service should be running\" {\n", | |
" (Get-Service -Name $Service).Status | Should -Be 'Running' -Because \"Service XXXX requires the service $Service to be running\"\n", | |
" }\n", | |
" }\n", | |
" }\n", | |
"}" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": ".NET (PowerShell)", | |
"language": "PowerShell", | |
"name": ".net-powershell" | |
}, | |
"language_info": { | |
"file_extension": ".ps1", | |
"mimetype": "text/x-powershell", | |
"name": "PowerShell", | |
"pygments_lexer": "powershell", | |
"version": "7.0" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 4 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment