Skip to content

Instantly share code, notes, and snippets.

@SQLvariant
Created December 6, 2019 18:26
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 SQLvariant/33cc78ba7c78f65015e22e6b06659352 to your computer and use it in GitHub Desktop.
Save SQLvariant/33cc78ba7c78f65015e22e6b06659352 to your computer and use it in GitHub Desktop.
Examples of lagging results in PowerShell Notebooks with v0.1.2 of the powershell_kernel
Display the source blob
Display the rendered blob
Raw
{
"metadata": {
"kernelspec": {
"name": "powershell",
"display_name": "PowerShell"
},
"language_info": {
"name": "powershell",
"codemirror_mode": "shell",
"mimetype": "text/x-sh",
"file_extension": ".ps1"
}
},
"nbformat_minor": 2,
"nbformat": 4,
"cells": [
{
"cell_type": "markdown",
"source": [
"I have put together a collection of commands which seem to occassionally (but not always) trigger \"Results Lag\" with the `powershell-kernel` used in Azure Data Studio.\n",
"\n",
"+ Sometimes, simply adding a second line of code triggers the issue.\n",
"+ Sometimes, the first time I run any command in a PowerShell Notebook I get a strange error message, and then I never see it again during that session."
],
"metadata": {
"azdata_cell_guid": "f545d73b-6ce3-4b12-909b-5924beecff2e"
}
},
{
"cell_type": "code",
"source": [
"Get-Process |\r\n",
"Format-Table -AutoSize"
],
"metadata": {
"azdata_cell_guid": "0d6b55ef-7301-446c-871c-7c1bcb7b3619"
},
"outputs": [
{
"name": "stdout",
"text": "At line:58 char:37\n+ %set_env VSCODE_NLS_CONFIG={\"locale\":\"en-us\",\"availableLanguages\":{}, ...\n+ ~~~~~~~~\nUnexpected token ':\"en-us\"' in expression or statement.\nAt line:58 char:45\n+ %set_env VSCODE_NLS_CONFIG={\"locale\":\"en-us\",\"availableLanguages\":{}, ...\n+ ~\nMissing argument in parameter list.\n + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException\n + FullyQualifiedErrorId : UnexpectedToken\n \n",
"output_type": "stream"
}
],
"execution_count": 1
},
{
"cell_type": "markdown",
"source": [
"The example below needs you to have Power BI Desktop open in order to get a good result. If you don't have Power BI Desktop open, you will receive an error. Only the last line will produce a result to be returned to the screen."
],
"metadata": {
"azdata_cell_guid": "be386d67-c818-4297-b7fb-c59a35c7ba39"
}
},
{
"cell_type": "code",
"source": [
"$pbidProcesses=(get-process PBIDesktop).Id\r\n",
"$processes=Get-NetTCPConnection\r\n",
"$connections=foreach ($pbidProcess in $pbidProcesses){ \r\n",
"$processes| ? {($_.OwningProcess -eq $pbidProcess) -and ($_.RemotePort -ne 0)} | sort-object $_.LocalPort\r\n",
"}\r\n",
"$likelyPBIDAnalysisServicesPort=$connections[0].RemotePort \r\n",
"write-output $likelyPBIDAnalysisServicesPort"
],
"metadata": {
"azdata_cell_guid": "fbd97a5c-0f63-4d9a-a5ee-4d76796b24f1"
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": "64057\n. { $pbidProcesses=(get-process PBIDesktop).Id\n>> $processes=Get-NetTCPConnection\n>> $connections=foreach ($pbidProcess in $pbidProcesses){ \n>> $processes| ? {($_.OwningProcess -eq $pbidProcess) -and ($_.RemotePort -ne 0)} | sort-object $_.LocalPort\n>> }\n>> $likelyPBIDAnalysisServicesPort=$connections[0].RemotePort \n>> write-output $likelyPBIDAnalysisServicesPort }\n>> \n"
}
],
"execution_count": 5
},
{
"cell_type": "code",
"source": [
"Get-ChildItem c:\\temp"
],
"metadata": {
"azdata_cell_guid": "5b816299-d9b8-4207-93c5-c0aff4a58994"
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": "64057\n"
}
],
"execution_count": 6
},
{
"cell_type": "code",
"source": [
"Get-Process"
],
"metadata": {
"azdata_cell_guid": "84fe6427-07f4-42a8-b6cb-b3c12c10abb7"
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": "ing\\Python\\Python36\\Scripts;C:\\Users\\aanelson\\azuredatastudio-python\\0.0.1\\Scripts;C:\\Users\\aanelson\\azuredatastudio-python\\0.0.1;C:\\ProgramData\\DockerDesktop\\version-bin;C:\\Program Files\\Docker\\Docker\\Resources\\bin;C:\\Program Files\\Python37\\Scripts\\;C:\\Program Files\\Python37\\;C:\\Program Files (x86)\\Python37-32\\Scripts\\;C:\\Program Files (x86)\\Python37-32\\;C:\\Python37\\Scripts\\;C:\\Python37\\;C:\\Program Files (x86)\\Microsoft SDKs\\Azure\\CLI2\\wbin;C:\\Program Files\\Common Files\\Microsoft Shared\\Microsoft Online Services;C:\\Program Files (x86)\\Common Files\\Microsoft Shared\\Microsoft Online Services;C:\\windows\\system32;C:\\windows;C:\\windows\\System32\\Wbem;C:\\windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\windows\\System32\\OpenSSH\\;C:\\ProgramData\\chocolatey\\bin;C:\\Program Files (x86)\\Microsoft SQL Server\\Client SDK\\ODBC\\130\\Tools\\Binn\\;C:\\Program Files (x86)\\Microsoft SQL Server\\140\\Tools\\Binn\\;C:\\Program Files (x86)\\Microsoft SQL Server\\140\\DTS\\Binn\\;C:\\Program Files (x86)\\Microsoft SQL Server\\140\\Tools\\Binn\\ManagementStudio\\;C:\\Program Files\\Microsoft VS Code\\bin;C:\\Program Files\\WindowsPowerShell\\Scripts;C:\\Program Files\\Git\\cmd;C:\\Program Files\\PowerShell\\6\\;C:\\Program Files (x86)\\Microsoft SQL Server\\150\\DTS\\Binn\\;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\WINDOWS\\System32\\OpenSSH\\;C:\\Program Files\\PowerShell\\7-preview\\preview;C:\\Program Files\\dotnet\\;C:\\Program Files (x86)\\dotnet\\;C:\\Program Files\\Microsoft SQL Server\\130\\Tools\\Binn\\;C:\\Program Files\\Microsoft SQL Server\\Client SDK\\ODBC\\170\\Tools\\Binn\\;C:\\Program Files\\Azure Data Studio\\bin;C:\\Users\\aanelson\\AppData\\Local\\CloudBuild;C:\\Program Files\\Python37\\Scripts\\;C:\\Program Files\\Python37\\;C:\\Program Files (x86)\\Python37-32\\Scripts\\;C:\\Program Files (x86)\\Python37-32\\;C:\\Python37\\Scripts\\;C:\\Python37\\;C:\\Program Files (x86)\\Microsoft SDKs\\Azure\\CLI2\\wbin;C:\\ProgramData\\DockerDesktop\\version-bin;C:\\Program Files\\Docker\\Docker\\Resources\\bin;C:\\Program Files\\Common Files\\Microsoft Shared\\Microsoft Online Services;C:\\Program Files (x86)\\Common Files\\Microsoft Shared\\Microsoft Online Services;C:\\windows\\system32;C:\\windows;C:\\windows\\System32\\Wbem;C:\\windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\windows\\System32\\OpenSSH\\;C:\\ProgramData\\chocolatey\\bin;C:\\Program Files (x86)\\Microsoft SQL Server\\Client SDK\\ODBC\\130\\Tools\\Binn\\;C:\\Program Files (x86)\\Microsoft SQL Server\\140\\Tools\\Binn\\;C:\\Program Files (x86)\\Microsoft SQL Server\\140\\DTS\\Binn\\;C:\\Program Files (x86)\\Microsoft SQL Server\\140\\Tools\\Binn\\ManagementStudio\\;C:\\Program Files\\Microsoft VS Code\\bin;C:\\Program Files\\WindowsPowerShell\\Scripts;C;C:\\Users\\aanelson\\AppData\\Local\\Programs\\Azure Data Studio - Insiders\\bin;C:\\Users\\aanelson\\AppData\\Local\\Programs\\Microsoft VS Code Insiders\\bin\n>> %set_env PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY;.PYW\n>> %set_env PIPE_LOGGING=true\n>> %set_env POWERSHELL_DISTRIBUTION_CHANNEL=MSI:Windows 10 Pro\n>> %set_env PROCESSOR_ARCHITECTURE=AMD64\n>> %set_env PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 142 Stepping 10, GenuineIntel\n>> %set_env PROCESSOR_LEVEL=6\n>> %set_env PROCESSOR_REVISION=8e0a\n>> %set_env ProgramData=C:\\ProgramData\n>> %set_env ProgramFiles=C:\\Program Files\n>> %set_env ProgramFiles(x86)=C:\\Program Files (x86)\n>> %set_env ProgramW6432=C:\\Program Files\n>> %set_env PSModulePath=C:\\Program Files\\WindowsPowerShell\\Modules;C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\Modules;C:\\Program Files (x86)\\Microsoft Azure Information Protection\\Powershell\n>> %set_env PUBLIC=C:\\Users\\Public\n>> %set_env SESSIONNAME=Console\n>> %set_env SystemDrive=C:\n>> %set_env SystemRoot=C:\\WINDOWS\n>> %set_env TEMP=C:\\Users\\aanelson\\AppData\\Local\\Temp\n>> %set_env TMP=C:\\Users\\aanelson\\AppData\\Local\\Temp\n>> %set_env UATDATA=C:\\windows\\CCM\\UATData\\D9F8C395-CAB8-491d-B8AC-179A1FE1BE77\n>> %set_env USERDNSDOMAIN=NORTHAMERICA.CORP.MICROSOFT.COM\n>> %set_env USERDOMAIN=NORTHAMERICA\n>> %set_env USERDOMAIN_ROAMINGPROFILE=NORTHAMERICA\n>> %set_env USERNAME=aanelson\n>> %set_env USERPROFILE=C:\\Users\\aanelson\n>> %set_env VERBOSE_LOGGING=true\n>> %set_env VSCODE_CWD=C:\\Users\\aanelson\\AppData\\Local\\Programs\\Azure Data Studio - Insiders\n>> %set_env VSCODE_HANDLES_UNCAUGHT_ERRORS=true\n>> %set_env VSCODE_IPC_HOOK=\\\\.\\pipe\\156e5c661582a0b154aeb104d5da915d-1.14.0-insider-main-sock\n>> %set_env VSCODE_IPC_HOOK_EXTHOST=\\\\.\\pipe\\vscode-ipc-8e52eb7f-09c7-4ffa-8921-25b4d316bb88-sock\n>> %set_env VSCODE_LOGS=C:\\Users\\aanelson\\AppData\\Roaming\\azuredatastudio\\logs\\20191120T075851\n>> %set_env VSCODE_LOG_STACK=true\n>> %set_env VSCODE_NLS_CONFIG={\"locale\":\"en-us\",\"availableLanguages\":{},\"_languagePackSupport\":true}\n>> %set_env VSCODE_NODE_CACHED_DATA_DIR=C:\\Users\\aanelson\\AppData\\Roaming\\azuredatastudio\\CachedData\\f976fc94187db2ed8853f895f7cf794a87aaf82a\n>> %set_env VSCODE_PID=6964\n>> %set_env windir=C:\\WINDOWS\n>> }\n>> \nAt line:58 char:37\n+ %set_env VSCODE_NLS_CONFIG={\"locale\":\"en-us\",\"availableLanguages\":{}, ...\n+ ~~~~~~~~\nUnexpected token ':\"en-us\"' in expression or statement.\nAt line:58 char:45\n+ %set_env VSCODE_NLS_CONFIG={\"locale\":\"en-us\",\"availableLanguages\":{}, ...\n+ ~\nMissing argument in parameter list.\n + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException\n + FullyQualifiedErrorId : UnexpectedToken\n \n"
}
],
"execution_count": 1
},
{
"cell_type": "code",
"source": [
"Get-Service -DisplayName SQL*"
],
"metadata": {
"azdata_cell_guid": "220bc328-1367-4240-9f31-748f1cd6dc43"
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": "\nName Value \n---- ----- \n$ } \n? True \n . \nargs {} \nConfirmPreference High \nconnections {MSFT_NetTCPConnection (InstanceID = \"::1??63333??::1??64057\"), MSFT_NetTCPConnection...\nConsoleFileName \nDebugPreference SilentlyContinue \nError {System.Management.Automation.IncompleteParseException: Missing closing '}' in statem...\nErrorActionPreference Continue \nErrorView NormalView \nExecutionContext System.Management.Automation.EngineIntrinsics \nfalse False \nforeach \nFormatEnumerationLimit 4 \nHOME C:\\Users\\aanelson \nHost System.Management.Automation.Internal.Host.InternalHost \nInformationPreference SilentlyContinue \ninput System.Collections.ArrayList+ArrayListEnumeratorSimple \nlikelyPBIDAnalysisServicesPort 64057 \nMaximumAliasCount 4096 \nMaximumDriveCount 4096 \nMaximumErrorCount 256 \nMaximumFunctionCount 4096 \nMaximumHistoryCount 4096 \nMaximumVariableCount 4096 \nMyInvocation System.Management.Automation.InvocationInfo \nNestedPromptLevel 0 \nnull \nOutputEncoding System.Text.ASCIIEncoding \npbidProcess 18932 \npbidProcesses 18932 \nPID 12332 \nprocesses {MSFT_NetTCPConnection (InstanceID = \"::??64061??::??0\"), MSFT_NetTCPConnection (Inst...\nPROFILE C:\\Users\\aanelson\\Documents\\WindowsPowerShell\\Microsoft.PowerShell_profile.ps1 \nProgressPreference Continue \nPSBoundParameters {} \nPSCommandPath \nPSCulture en-US \nPSDefaultParameterValues {} \nPSEdition Desktop \nPSEmailServer \nPSHOME C:\\Windows\\System32\\WindowsPowerShell\\v1.0 \nPSScriptRoot \nPSSessionApplicationName wsman \nPSSessionConfigurationName http://schemas.microsoft.com/powershell/Microsoft.PowerShell \nPSSessionOption System.Management.Automation.Remoting.PSSessionOption \nPSUICulture en-US \nPSVersionTable {PSVersion, PSEdition, PSCompatibleVersions, BuildVersion...} \nPWD C:\\Users\\aanelson \nShellId Microsoft.PowerShell \nStackTrace \ntrue True \nVerbosePreference SilentlyContinue \nWarningPreference Continue \nWhatIfPreference False \n\n\n"
}
],
"execution_count": 8
},
{
"cell_type": "code",
"source": [
"dir Variable:\\"
],
"metadata": {
"azdata_cell_guid": "f3077e9c-72b8-4514-8050-81e0a34554b7"
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": "\nStatus Name DisplayName \n------ ---- ----------- \nRunning SQLWriter SQL Server VSS Writer \n\n\n"
}
],
"execution_count": 9
}
]
}
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment