Skip to content

Instantly share code, notes, and snippets.

@SQLDBAWithABeard
Created February 7, 2020 09:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SQLDBAWithABeard/545b9c353c609ff5bb1bff4b6ccb57cd to your computer and use it in GitHub Desktop.
Save SQLDBAWithABeard/545b9c353c609ff5bb1bff4b6ccb57cd to your computer and use it in GitHub Desktop.
Failing .NET POwerShell Notebook
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# This is a new Notebook\n",
"\n",
"That has been written in .NET Interactive\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<pre></pre>\r\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<pre>Name Value</pre>\r\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<pre>---- -----</pre>\r\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<pre>PSVersion 7.0.0-rc.1</pre>\r\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<pre>PSEdition Core</pre>\r\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<pre>GitCommitId 7.0.0-rc.1</pre>\r\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<pre>OS Microsoft Windows 10.0.18362</pre>\r\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<pre>Platform Win32NT</pre>\r\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<pre>PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}</pre>\r\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<pre>PSRemotingProtocolVersion 2.3</pre>\r\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<pre>SerializationVersion 1.1.0.1</pre>\r\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<pre>WSManStackVersion 3.0</pre>\r\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<pre></pre>\r\n"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"$psversiontable"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<pre>Describe: The &#39;Describe&#39; command was found in the module &#39;Pester&#39;, but the module could not be loaded. For more information, run &#39;Import-Module Pester&#39;.</pre>\r\n"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"Describe \"Do things Exist\" {\n",
" Context \"Servers\" {\n",
" It \"The Server returns a ping - This will fail - Wrong Server Name\" {\n",
" (Test-Connection Exeter -Count 1 -Quiet -ErrorAction SilentlyContinue ) | Should Be $true\n",
" }\n",
" It \"The Server Bolton returns a ping\" {\n",
" (Test-Connection Bolton -Count 1 -Quiet -ErrorAction SilentlyContinue ) | Should Be $true\n",
" }\n",
" It \"Rob-XPS Operating System Version\" {\n",
" (Get-CimInstance -ClassName Win32_OperatingSystem).Version | Should Be '10.0.16299'\n",
" }\n",
" }\n",
"}\n"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<pre></pre>\r\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<pre></pre>\r\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<pre> Directory: C:\\Users\\mrrob\\Documents\\PowerShell\\Modules</pre>\r\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<pre></pre>\r\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<pre>ModuleType Version PreRelease Name PSEdition ExportedCommands</pre>\r\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<pre>---------- ------- ---------- ---- --------- ----------------</pre>\r\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<pre>Script 4.9.0 Pester Desk {Describe, Context, It, Should…}</pre>\r\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<pre>Script 4.8.1 Pester Desk {Describe, Context, It, Should…}</pre>\r\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<pre></pre>\r\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<pre> Directory: C:\\Program Files\\WindowsPowerShell\\Modules</pre>\r\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<pre></pre>\r\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<pre>ModuleType Version PreRelease Name PSEdition ExportedCommands</pre>\r\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<pre>---------- ------- ---------- ---- --------- ----------------</pre>\r\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<pre>Script 4.8.1 Pester Desk {Describe, Context, It, Should…}</pre>\r\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<pre>Script 3.4.0 Pester Desk {Describe, Context, It, Should…}</pre>\r\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<pre></pre>\r\n"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"Get-Module Pester -ListAvailable"
]
},
{
"cell_type": "code",
"execution_count": 9,
"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[&#39;Get-CimInstance&#39;] = Get-Command -Name Get-CimInstance -Module CimCmdlets @safeCommandLookupParameters\r\n",
"\r\n",
" | ^ The term &#39;Get-CimInstance&#39; 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 &#39;Pester.psm1&#39;, listed in field &#39;ModuleToProcess/RootModule&#39; of module manifest &#39;C:\\Users\\mrrob\\Documents\\PowerShell\\Modules\\pester\\4.9.0\\pester.psd1&#39; was not processed because no valid module was found in any module directory.</pre>\r\n"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"ipmo pester "
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<pre>Import-Module: The term &#39;Get-CimInstance&#39; is not recognized as the name of a cmdlet, function, script file, or operable program.\r\n",
"Check the spelling of the name, or if a path was included, verify that the path is correct and try again.</pre>\r\n"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"ipmo dbachecks"
]
},
{
"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