PowerShell is a task automation program used in Windows Operating System developed by Microsoft. It consists of a command-line shell and a scripting language.

Popular New Releases in PowerShell

Scoop

Version 0.1.0

posh-git

v1.0.0

virtual-environments

macOS 10.15 (20220419 update)

oh-my-posh2

2.0.496

Sophia-Script-for-Windows

6.0.14

Popular Libraries in PowerShell

Scoop

by ScoopInstaller doticonpowershelldoticon

star image 15406 doticonUnlicense

A command-line installer for Windows.

scoop

by lukesampson doticonpowershelldoticon

star image 13514 doticonUnlicense

A command-line installer for Windows.

Windows10Debloater

by Sycnex doticonpowershelldoticon

star image 10611 doticonMIT

Script to remove Windows 10 bloatware.

blazor

by dotnet doticonpowershelldoticon

star image 9335 doticonApache-2.0

Blazor moved to https://github.com/dotnet/aspnetcore

PowerSploit

by PowerShellMafia doticonpowershelldoticon

star image 8456 doticonNOASSERTION

PowerSploit - A PowerShell Post-Exploitation Framework

azure-docs

by MicrosoftDocs doticonpowershelldoticon

star image 6965 doticonNOASSERTION

Open source documentation of Microsoft Azure

Empire

by EmpireProject doticonpowershelldoticon

star image 6142 doticonBSD-3-Clause

Empire is a PowerShell and Python post-exploitation agent.

posh-git

by dahlbyk doticonpowershelldoticon

star image 6007 doticonMIT

A PowerShell environment for Git

atomic-red-team

by redcanaryco doticonpowershelldoticon

star image 5860 doticonMIT

Small and highly portable detection tests based on MITRE's ATT&CK.

Trending New libraries in PowerShell

win10script

by ChrisTitusTech doticonpowershelldoticon

star image 2410 doticonMIT

This is the Ultimate Windows 10 Script from a creation from multiple debloat scripts and gists from github.

PowerRemoteDesktop

by DarkCoderSc doticonpowershelldoticon

star image 1406 doticonApache-2.0

Remote Desktop entirely coded in PowerShell.

AZ-104-MicrosoftAzureAdministrator

by MicrosoftLearning doticonpowershelldoticon

star image 1258 doticonMIT

AZ-104 Microsoft Azure Administrator

PrivescCheck

by itm4n doticonpowershelldoticon

star image 1178 doticonBSD-3-Clause

Privilege Escalation Enumeration Script for Windows

at-ps

by specterops doticonpowershelldoticon

star image 1165 doticonNOASSERTION

Adversary Tactics - PowerShell Training

windowsterminal-shell

by lextm doticonpowershelldoticon

star image 1146 doticonMIT

Install/uninstall scripts for Windows Terminal context menu items

Sparrow

by cisagov doticonpowershelldoticon

star image 1136 doticonCC0-1.0

Sparrow.ps1 was created by CISA's Cloud Forensics team to help detect possible compromised accounts and applications in the Azure/m365 environment.

taowu-cobalt-strike

by pandasec888 doticonpowershelldoticon

star image 1027 doticon

CSS-Exchange

by microsoft doticonpowershelldoticon

star image 1005 doticonMIT

Exchange Server support tools and scripts

Top Authors in PowerShell

1

MicrosoftDocs

1664 Libraries

star icon29280

2

freddydk

837 Libraries

star icon2

3

microsoft

230 Libraries

star icon19664

4

Azure

103 Libraries

star icon7897

5

dfinke

90 Libraries

star icon3052

6

gavz

87 Libraries

star icon15

7

dotnet

75 Libraries

star icon15591

8

Azure-Samples

70 Libraries

star icon1698

9

jdhitsolutions

68 Libraries

star icon1473

10

damienvanrobaeys

65 Libraries

star icon428

1

1664 Libraries

star icon29280

2

837 Libraries

star icon2

3

230 Libraries

star icon19664

4

103 Libraries

star icon7897

5

90 Libraries

star icon3052

6

87 Libraries

star icon15

7

75 Libraries

star icon15591

8

70 Libraries

star icon1698

9

68 Libraries

star icon1473

10

65 Libraries

star icon428

Trending Kits in PowerShell

No Trending Kits are available at this moment for PowerShell

Trending Discussions on PowerShell

Azure Pipelines local agent failing to connect with SSL error

Problems with creating an azure function in visual studio 2022

Error when deploying react app and it keeps sayings << Plugin "react" was conflicted between "package.json » eslint-config-react-app » >>

What decides if a value is returned from a PowerShell function?

Getting error on running command `npm run build`, error `TypeError: MiniCssExtractPlugin is not a constructor`

Why does my .NET Core 6 console app not want to run in CLI?

How to use Windows.Storage.Streams.DataWriter with PowerShell

BTSKTask AddResource - How to raise an error in case the command fails

How can I suppress or resolve "info: detecting host provider for..." in Git?

Why does nvidia-smi return "GPU access blocked by the operating system" in WSL2 under Windows 10 21H2

QUESTION

Azure Pipelines local agent failing to connect with SSL error

Asked 2022-Mar-29 at 19:29

We have an on premise server (Windows Server 2012 R2) with an Azure Pipelines agent running on it. Today (31st Jan 2022) this agent could not longer connect to our Azure DevOps organisation.

Log file of azure agent

Judging by the log files, I assume this is because it is trying to connect with an older TLS version, which as of today is no longer available - https://devblogs.microsoft.com/devops/azure-devops-services-to-require-tls-1-2/

So I followed the instructions on how to make sure TLS 1.2 was enabled, and confirmed my settings in the registry editor and by running the PowerShell script suggested here - https://docs.microsoft.com/en-us/security/engineering/solving-tls1-problem#update-windows-powershell-scripts-or-related-registry-settings

All seems ok, yet it still fails to connect with the same issue. The machine has been restarted as well. If I try the URL it is requesting in the in built Internet Explorer browser, it fails, but with Chrome it succeeds, so it must still be trying to connect with TLS 1.2, but I don't know why. I've tried reinstalling the agent (with the latest build) as well but it fails on the same error. Any suggestions?

ANSWER

Answered 2022-Jan-31 at 23:27

Enabling below Cyphers with IISCrypto on the server helped us fix the issue

Cipher Suites

TLS 1.2 (suites in server-preferred order) TLS

  • _DHE_RSA_WITH_AES_256_GCM_SHA384 (0x9f) DH 2048 bits FS 256 TLS
  • DHE_RSA_WITH_AES_128_GCM_SHA256 (0x9e) DH 2048 bits FS 128

This from Vijay's solution

Source https://stackoverflow.com/questions/70929356

QUESTION

Problems with creating an azure function in visual studio 2022

Asked 2022-Mar-22 at 12:55

So I right click on the solution > add > new project > find azure function > choose template > create that

And then nothing happens. If I swap to folder view, I see a new folder made for the function, but its an empty folder.

Weirdest thing is, this was working perfectly fine and a moment later, it became how it is right now. I've not updated vs in between, I've not restarted in between. It was literally closed vs, opened again, and then vs broke.

Older solutions that has functions in them, tried creating a new one, doesn't work same story. Made new solutions and start it off with creating a function, didn't work as well. Reinstalled vs, also did not help, still the same issue. Any ideas how I broke vs?

Also, this works from powershell, I can create functions from there and then go back to vs to add an existing project. However the functions I've build using this method had runtime errors (I think) when I publish them into azure. Regardless, I really would like to be able to create functions normally in vs.

ANSWER

Answered 2022-Mar-22 at 12:55

As we can see from the comment section of the question, the solution was:

  • Go into Tools -> Get Tools and Features
  • download the .Net desktop development

As Maybemonday described in his/her comment, functions can be created afterwards.

Source https://stackoverflow.com/questions/71313799

QUESTION

Error when deploying react app and it keeps sayings << Plugin "react" was conflicted between "package.json » eslint-config-react-app » >>

Asked 2022-Mar-09 at 14:04

I have been having a little bit of issues when deploying my create react app, as it fails to compile and tells me Plugin "react" was conflicted between "package.json » eslint-config-react-app »

I was wondering if somebody has encountered the same issue and knows how to solve it, thank you! I am still very new to all this.

eHere is what my windows powershell tells me once I npm start and launches

This is what my localhost looks like once my react app launches

ANSWER

Answered 2021-Dec-17 at 09:47

There is a conflict in the casing

C:\Users\Ruben|desktop\reactapp\test.... whereas the nodemodules is looking for C:\Users\Ruben|Desktop\Reactapp\test....

This is a windows specific problem, and previously react would have run the app regardless of this difference. Not anymore it seems.

The solution I used was to locate the folder and open with code; that ensures that the path matches directly with what is stored in node modules

Source https://stackoverflow.com/questions/70377211

QUESTION

What decides if a value is returned from a PowerShell function?

Asked 2022-Feb-07 at 21:09

I'm trying to figure out what dictates if a value is returned from a PowerShell function or not, and I've run into some oddities. The about_return docs say:

In PowerShell, the results of each statement are returned as output, even without a statement that contains the Return keyword.

But this seems to glaze over details. If I run this:

1function My-Function {
2    1
3    [System.Console]::WriteLine("Hello")
4    $null
5    $true
6    $false
7    0
8    2
9}
10

Running this returns an array of (along with printing "Hello"):

1function My-Function {
2    1
3    [System.Console]::WriteLine("Hello")
4    $null
5    $true
6    $false
7    0
8    2
9}
101
11True
12False
130
142
15

Which means that $null isn't auto-returned. Then I tried incrementing since I'm doing using that in a function:

1function My-Function {
2    1
3    [System.Console]::WriteLine("Hello")
4    $null
5    $true
6    $false
7    0
8    2
9}
101
11True
12False
130
142
15function My-Function {
16    $n = 1
17    $n
18    $n++
19    ($n++)
20    -join @(1, 2, 3)
21    (-join @(1, 2, 3))
22}
23

Returns:

1function My-Function {
2    1
3    [System.Console]::WriteLine("Hello")
4    $null
5    $true
6    $false
7    0
8    2
9}
101
11True
12False
130
142
15function My-Function {
16    $n = 1
17    $n
18    $n++
19    ($n++)
20    -join @(1, 2, 3)
21    (-join @(1, 2, 3))
22}
231
242
25123
26123
27

So, $n and $n++ were returned, but ($n++) wasn't? But then when compared to another operator (-join), it's the same in each case. Why does wrapping parenthesis around $n++ prevent it from being returned, and why don't other operators behave the same? This is even more confusing since the = operator appears to work in the opposite way:

1function My-Function {
2    1
3    [System.Console]::WriteLine("Hello")
4    $null
5    $true
6    $false
7    0
8    2
9}
101
11True
12False
130
142
15function My-Function {
16    $n = 1
17    $n
18    $n++
19    ($n++)
20    -join @(1, 2, 3)
21    (-join @(1, 2, 3))
22}
231
242
25123
26123
27function My-Function {
28    ($n = 1)
29    $n
30    $n++
31    ($n++)
32}
33

Returns:

1function My-Function {
2    1
3    [System.Console]::WriteLine("Hello")
4    $null
5    $true
6    $false
7    0
8    2
9}
101
11True
12False
130
142
15function My-Function {
16    $n = 1
17    $n
18    $n++
19    ($n++)
20    -join @(1, 2, 3)
21    (-join @(1, 2, 3))
22}
231
242
25123
26123
27function My-Function {
28    ($n = 1)
29    $n
30    $n++
31    ($n++)
32}
331
341
352
36

Now wrapping the assignment causes it to be returned, whereas wrapping $n++ causes it to not be returned.

In summary, I'd just like to know a straightforward way of being able to look at a line of code in a function, and determine if it will cause a value to be returned or not.

ANSWER

Answered 2022-Feb-07 at 21:09

This section discusses the specific statements from your sample functions.
See the bottom section for background information.

  • $n = 1 and $n++ are assignments and therefore do not produce output.
  • $n is an expression whose value is output
  • $null - ditto, but even though it is output, it doesn't display by default
  • ($n++) - due to enclosure in (...) - turns the assignment into an expression and therefore does output the assigned value (too).
    • However, because you've used the post-increment form of the assignment, it is the old value that is output, not the now incremented value; to increment first (pre-increment) and then output, use (++$n)
  • [System.Console]::WriteLine("Hello") prints directly to the console, which bypasses PowerShell's system of output streams.
    • This means you cannot capture or redirect such output from inside PowerShell (see the next section).

PowerShell's output ("return value") behavior:

Tip of the hat to iRon for his help.

PowerShell, following the model of traditional shells, is organized around streams - see the conceptual about_Redirection help topic for an overview of all 6 streams that PowerShell supports.[1]

That is, any statement - and therefore potentially multiple ones - in a script or function can write to any of the output streams.

The primary output stream, meant to convey data, is the success output stream (whose number is 1), and only it is sent through the pipeline by default, and therefore by default only it is captured in a variable, suppressed, or redirected to a file.

There are two ways to write to the success output stream, i.e. to produce data output:

  • Explicitly, with a Write-Output call - although that is rarely needed.

  • Typically implicitly, by neither capturing, suppressing, nor redirecting output produced by a statement.

    • In other words: Output from any command (e.g., Get-ChildItem *.txt) or expression (e.g, 1 + 2 or (42).ToString('x')) is sent to the success output stream by default.

    • Unlike in traditional programming languages, return is not needed to produce output - in fact, its primary purpose is to exit the enclosing scope independently of any output the scope produces, though as a syntactic convenience you can combine the two aspects:

      • return <command-or-expression> is in effect the same as the following two statements, the first of which (potentially) produces output, the second of which exits the scope: <command-or-expression>; return
    • This implicit output behavior is convenient and and allows for concise, expressive code, but can also be a pitfall: it is easy to accidentally produce output - typically from a .NET method whose return value isn't needed (see this question for an example).

      • iRon's GitHub feature request #15781 discusses one potential way to remedy this problem: introduction of an opt-in strict mode that only permits using explicit output statements (Write-Output, return) in order to produce output.

      • This answer shows troubleshooting techniques you can use with the currently available features.

As for assignments - e.g. $n = 1; $n += 1; ++$n; $n--:

  • By default they do not produce output.
    • A hybrid case is the chaining form of a multi-assignment, e.g. $a = $b = 1, which assigns 1 to both variables: statement-internally the assignment value is passed through, but the statement as a whole has no output.
  • However, as an opt-in you can make them pass the value(s) being assigned through via (...), the grouping operator; e.g. ($n = 1) both assigns 1 to variable $n and outputs 1, which allows it to participate in larger expressions, such as ($n = 1) -gt 0
    • Note that the related $(...) (subexpression operator) and @(...) (array-subexpression operator) do not have that effect - they wrap one or more entire statement(s), without affecting the enclosed statements' intrinsic output behavior; e.g. $($n = 1) does not produce output, because $n = 1 by itself doesn't produce output; however, $(($n = 1)) does, because ($n = 1) by itself does.

As for output enumeration behavior:

  • By default, PowerShell enumerates collections that are being output, in the spirit of streaming output: That is, it sends a collection's elements to the pipeline, one by one.

  • In the rare event that you do need to output a collection as a whole - which in general should be avoided, so as not to confound other commands participating in a pipeline, which usually do expect object-by-object input - you have two options:

    • , $collection (sic; uses an aux. one-element wrapper array)
    • More explicitly, but less efficiently: Write-Output -NoEnumerate $collection
    • See this answer for more information.

As for outputting $null:

  • $null is output to the pipeline, but by default doesn't show.

    • $null by itself produces no visible output,

    • but the following returns $true, demonstrating that the value was sent:

1function My-Function {
2    1
3    [System.Console]::WriteLine(&quot;Hello&quot;)
4    $null
5    $true
6    $false
7    0
8    2
9}
101
11True
12False
130
142
15function My-Function {
16    $n = 1
17    $n
18    $n++
19    ($n++)
20    -join @(1, 2, 3)
21    (-join @(1, 2, 3))
22}
231
242
25123
26123
27function My-Function {
28    ($n = 1)
29    $n
30    $n++
31    ($n++)
32}
331
341
352
36$null | ForEach-Object { $null -eq $_ } # -&gt; $true
37
  • Note that PowerShell also has an "array-valued $null" value that it uses to represent the lack of output from a command, which is technically represented as the [System.Management.Automation.Internal.AutomationNull]::Value singleton. In expression contexts, this values is treated the same as $null, but in the pipeline it behaves like an enumerable without elements and therefore sends nothing through the pipeline - see this answer for more information.

  • As for suppressing (discarding) unwanted output / redirecting to a file:

    • The best general-purpose way to suppress a statement's success output is to assign to $null ($null = ...); e.g.:

    1function My-Function {
    2    1
    3    [System.Console]::WriteLine(&quot;Hello&quot;)
    4    $null
    5    $true
    6    $false
    7    0
    8    2
    9}
    101
    11True
    12False
    130
    142
    15function My-Function {
    16    $n = 1
    17    $n
    18    $n++
    19    ($n++)
    20    -join @(1, 2, 3)
    21    (-join @(1, 2, 3))
    22}
    231
    242
    25123
    26123
    27function My-Function {
    28    ($n = 1)
    29    $n
    30    $n++
    31    ($n++)
    32}
    331
    341
    352
    36$null | ForEach-Object { $null -eq $_ } # -&gt; $true
    37 # .Add() outputs a value, which is usually unwanted.
    38 $null = ($list = [System.Collections.ArrayList]::new()).Add('hi')
    39
  • Note: The following discusses output suppression, via $null as the redirection target, but applies analogously to redirecting output to a file, by specifying a file name or path as the target.[2]

    • To selectively suppress a different output stream, prefix >$null with its number; e.g. 3>$null suppresses warning stream output.

    • To suppress output from all streams, which in the case of external programs covers both stdout and stderr, use redirection *>$null.

  • As for merging output streams:

    • Only the success output stream (stream number 1) can be merged into.
    • You can selectively merge one or more output streams into it (e.g. 2>&1 and/or 3>&1), or merge all (others): *>&1
    • In the resulting merged success output stream you can still identify what (non-success) stream a given object came from, by examining its type; e.g., error stream objects (stream 2) are [System.Management.Automation.ErrorRecord] instances - see this answer for more information.

    As for bypassing PowerShell's system of streams:

    • Out-Host and [Console]::WriteLine() calls bypass PowerShell's output streams and write directly to the host / console (terminal). (A host is any environment that hosts the PowerShell engine, which is typically, but not necessarily a console (terminal); examples of other hosts are the PowerShell SDK and the host used in PowerShell remoting).

      • As such, their output cannot be captured, suppressed or redirected from inside PowerShell.
    • Write-Host formerly unconditionally bypassed PowerShell's output streams and still goes to the host by default, but - since PowerShell version 5 - routes its output via the information stream (stream number 6), where it can be captured / redirected on demand - see this answer for more information.

    As for how output is formatted:

    • If output isn't captured, suppressed, or redirected, it is sent to the host (console) by default, where it is rendered based on PowerShell's rich and customizable for-display output-formatting system. See this answer for a concise overview.

    • Note that the resulting representations are designed for the human observer, not for programmatic processing. While PowerShell maintains a clear separation between the actual data and its representation, the caveat is that you do end up with just the for-display, string representation in the following scenarios:

      • When you use Out-File or its effective aliases, the redirection operators > and >>
      • When you (implicitly) send output to the outside world (an outside caller's stdout stream - see below).
      • In both cases, if later programmatic processing is required, the data must be transformed into a structured text format, such as CSV (Export-Csv or ConvertTo-Csv) or JSON (using ConvertTo-Json).

    As for how the outside world sees PowerShell's output streams:

    • IPC (inter-process communication) at the OS level knows only two output streams: stdout (standard output) and stderr (standard error), which forces PowerShell to map its 6 output streams onto these two in order to return streaming output to an outside caller.

    • While it would make sense to map PowerShell's success output stream to stdout and all other streams to stderr, unfortunately all streams are reported via stdout by default as of PowerShell 7.2 - although selectively redirecting stderr in the calling process (typically with 2>) does send PowerShell's error stream (only) to that redirection target. See the bottom section of this answer for more information.

    • Also note that PowerShell as of version 7.2 only ever communicates via text (strings) with outside callers as well as with external programs called from inside a PowerShell sessions, which means that character-encoding issues can arise - see this answer for more information.


    [1] Note that PowerShell has no concept of an input stream as such, and therefore also does not support the stdin redirection operator < familiar from other shells. Instead, commands receive streaming input (only) via the pipeline. In order to receive data from the outside world, via the PowerShell CLI's stdin stream, the automatic $input variable must be used - see this answer.

    [2] Using > (or >>) to redirect to a file effectively uses the Out-File cmdlet behind the scenes, and therefore its default character encoding, which is "Unicode" (UTF-16LE) in Windows PowerShell, and BOM-less UTF-8 in PowerShell (Core) 7+. However, in PowerShell version 5.1 and above you can control this encoding via the $PSDefaultParameterValues preference variable - see this answer.

    Source https://stackoverflow.com/questions/69791276

    QUESTION

    Getting error on running command `npm run build`, error `TypeError: MiniCssExtractPlugin is not a constructor`

    Asked 2022-Jan-16 at 13:16

    I'm creating an app using react it runs fine on npm start but when I try to build the app, this show the following error.

    1PS D:\ ****\ **\*\profile&gt; npm run build
    2
    3&gt; profile@0.1.0 build
    4&gt; react-scripts build
    5
    6D:\ ****\ **\profile\node_modules\react-scripts\config\webpack.config.js:664
    7        new MiniCssExtractPlugin({
    8        ^
    9
    10TypeError: MiniCssExtractPlugin is not a constructor
    11    at module.exports (D:\Documents\Project\React\profile\node_modules\react-scripts\config\webpack.config.js:664:9)
    12    at Object.&lt;anonymous&gt; (D:\Documents\Project\React\profile\node_modules\react-scripts\scripts\build.js:58:16)
    13    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    14    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    15    at Module.load (node:internal/modules/cjs/loader:981:32)
    16    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    17    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    18    at node:internal/main/run_main_module:17:47
    19
    20

    I'm using

    Package name Version
    node 16.13.2
    npm 8.1.2
    npx 8.1.2

    This is my package.json file.

    1PS D:\ ****\ **\*\profile&gt; npm run build
    2
    3&gt; profile@0.1.0 build
    4&gt; react-scripts build
    5
    6D:\ ****\ **\profile\node_modules\react-scripts\config\webpack.config.js:664
    7        new MiniCssExtractPlugin({
    8        ^
    9
    10TypeError: MiniCssExtractPlugin is not a constructor
    11    at module.exports (D:\Documents\Project\React\profile\node_modules\react-scripts\config\webpack.config.js:664:9)
    12    at Object.&lt;anonymous&gt; (D:\Documents\Project\React\profile\node_modules\react-scripts\scripts\build.js:58:16)
    13    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    14    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    15    at Module.load (node:internal/modules/cjs/loader:981:32)
    16    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    17    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    18    at node:internal/main/run_main_module:17:47
    19
    20{
    21  &quot;name&quot;: &quot;profile&quot;,
    22  &quot;version&quot;: &quot;0.1.0&quot;,
    23  &quot;private&quot;: true,
    24  &quot;dependencies&quot;: {
    25    &quot;@testing-library/jest-dom&quot;: &quot;^5.16.1&quot;,
    26    &quot;@testing-library/react&quot;: &quot;^12.1.2&quot;,
    27    &quot;@testing-library/user-event&quot;: &quot;^13.5.0&quot;,
    28    &quot;react&quot;: &quot;^17.0.2&quot;,
    29    &quot;react-dom&quot;: &quot;^17.0.2&quot;,
    30    &quot;react-scripts&quot;: &quot;5.0.0&quot;,
    31    &quot;web-vitals&quot;: &quot;^2.1.3&quot;
    32  },
    33  &quot;scripts&quot;: {
    34    &quot;start&quot;: &quot;react-scripts start&quot;,
    35    &quot;build&quot;: &quot;react-scripts build&quot;,
    36    &quot;test&quot;: &quot;react-scripts test&quot;,
    37    &quot;eject&quot;: &quot;react-scripts eject&quot;
    38  },
    39  &quot;eslintConfig&quot;: {
    40    &quot;extends&quot;: [
    41      &quot;react-app&quot;,
    42      &quot;react-app/jest&quot;
    43    ]
    44  },
    45  &quot;browserslist&quot;: {
    46    &quot;production&quot;: [
    47      &quot;&gt;0.2%&quot;,
    48      &quot;not dead&quot;,
    49      &quot;not op_mini all&quot;
    50    ],
    51    &quot;development&quot;: [
    52      &quot;last 1 chrome version&quot;,
    53      &quot;last 1 firefox version&quot;,
    54      &quot;last 1 safari version&quot;
    55    ]
    56  }
    57}
    58
    59

    I also tried to re-install whole node package, but I'm getting this error again and again.

    ANSWER

    Answered 2022-Jan-15 at 08:50

    There is an update to mini-css-extract-plugin in version 2.5.0. I temporarily fixed it by adding in package.json:

    1PS D:\ ****\ **\*\profile&gt; npm run build
    2
    3&gt; profile@0.1.0 build
    4&gt; react-scripts build
    5
    6D:\ ****\ **\profile\node_modules\react-scripts\config\webpack.config.js:664
    7        new MiniCssExtractPlugin({
    8        ^
    9
    10TypeError: MiniCssExtractPlugin is not a constructor
    11    at module.exports (D:\Documents\Project\React\profile\node_modules\react-scripts\config\webpack.config.js:664:9)
    12    at Object.&lt;anonymous&gt; (D:\Documents\Project\React\profile\node_modules\react-scripts\scripts\build.js:58:16)
    13    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    14    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    15    at Module.load (node:internal/modules/cjs/loader:981:32)
    16    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    17    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    18    at node:internal/main/run_main_module:17:47
    19
    20{
    21  &quot;name&quot;: &quot;profile&quot;,
    22  &quot;version&quot;: &quot;0.1.0&quot;,
    23  &quot;private&quot;: true,
    24  &quot;dependencies&quot;: {
    25    &quot;@testing-library/jest-dom&quot;: &quot;^5.16.1&quot;,
    26    &quot;@testing-library/react&quot;: &quot;^12.1.2&quot;,
    27    &quot;@testing-library/user-event&quot;: &quot;^13.5.0&quot;,
    28    &quot;react&quot;: &quot;^17.0.2&quot;,
    29    &quot;react-dom&quot;: &quot;^17.0.2&quot;,
    30    &quot;react-scripts&quot;: &quot;5.0.0&quot;,
    31    &quot;web-vitals&quot;: &quot;^2.1.3&quot;
    32  },
    33  &quot;scripts&quot;: {
    34    &quot;start&quot;: &quot;react-scripts start&quot;,
    35    &quot;build&quot;: &quot;react-scripts build&quot;,
    36    &quot;test&quot;: &quot;react-scripts test&quot;,
    37    &quot;eject&quot;: &quot;react-scripts eject&quot;
    38  },
    39  &quot;eslintConfig&quot;: {
    40    &quot;extends&quot;: [
    41      &quot;react-app&quot;,
    42      &quot;react-app/jest&quot;
    43    ]
    44  },
    45  &quot;browserslist&quot;: {
    46    &quot;production&quot;: [
    47      &quot;&gt;0.2%&quot;,
    48      &quot;not dead&quot;,
    49      &quot;not op_mini all&quot;
    50    ],
    51    &quot;development&quot;: [
    52      &quot;last 1 chrome version&quot;,
    53      &quot;last 1 firefox version&quot;,
    54      &quot;last 1 safari version&quot;
    55    ]
    56  }
    57}
    58
    59 &quot;overrides&quot;: {
    60    &quot;mini-css-extract-plugin&quot;: &quot;2.4.5&quot;
    61  }
    62

    for your npm version first try:

    1PS D:\ ****\ **\*\profile&gt; npm run build
    2
    3&gt; profile@0.1.0 build
    4&gt; react-scripts build
    5
    6D:\ ****\ **\profile\node_modules\react-scripts\config\webpack.config.js:664
    7        new MiniCssExtractPlugin({
    8        ^
    9
    10TypeError: MiniCssExtractPlugin is not a constructor
    11    at module.exports (D:\Documents\Project\React\profile\node_modules\react-scripts\config\webpack.config.js:664:9)
    12    at Object.&lt;anonymous&gt; (D:\Documents\Project\React\profile\node_modules\react-scripts\scripts\build.js:58:16)
    13    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    14    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    15    at Module.load (node:internal/modules/cjs/loader:981:32)
    16    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    17    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    18    at node:internal/main/run_main_module:17:47
    19
    20{
    21  &quot;name&quot;: &quot;profile&quot;,
    22  &quot;version&quot;: &quot;0.1.0&quot;,
    23  &quot;private&quot;: true,
    24  &quot;dependencies&quot;: {
    25    &quot;@testing-library/jest-dom&quot;: &quot;^5.16.1&quot;,
    26    &quot;@testing-library/react&quot;: &quot;^12.1.2&quot;,
    27    &quot;@testing-library/user-event&quot;: &quot;^13.5.0&quot;,
    28    &quot;react&quot;: &quot;^17.0.2&quot;,
    29    &quot;react-dom&quot;: &quot;^17.0.2&quot;,
    30    &quot;react-scripts&quot;: &quot;5.0.0&quot;,
    31    &quot;web-vitals&quot;: &quot;^2.1.3&quot;
    32  },
    33  &quot;scripts&quot;: {
    34    &quot;start&quot;: &quot;react-scripts start&quot;,
    35    &quot;build&quot;: &quot;react-scripts build&quot;,
    36    &quot;test&quot;: &quot;react-scripts test&quot;,
    37    &quot;eject&quot;: &quot;react-scripts eject&quot;
    38  },
    39  &quot;eslintConfig&quot;: {
    40    &quot;extends&quot;: [
    41      &quot;react-app&quot;,
    42      &quot;react-app/jest&quot;
    43    ]
    44  },
    45  &quot;browserslist&quot;: {
    46    &quot;production&quot;: [
    47      &quot;&gt;0.2%&quot;,
    48      &quot;not dead&quot;,
    49      &quot;not op_mini all&quot;
    50    ],
    51    &quot;development&quot;: [
    52      &quot;last 1 chrome version&quot;,
    53      &quot;last 1 firefox version&quot;,
    54      &quot;last 1 safari version&quot;
    55    ]
    56  }
    57}
    58
    59 &quot;overrides&quot;: {
    60    &quot;mini-css-extract-plugin&quot;: &quot;2.4.5&quot;
    61  }
    62npm i -D --save-exact mini-css-extract-plugin@2.4.5
    63

    Source https://stackoverflow.com/questions/70719667

    QUESTION

    Why does my .NET Core 6 console app not want to run in CLI?

    Asked 2022-Jan-11 at 21:44

    [Background Information]

    So I installed the new Visual Studio 2022 and decided to try out .NET Core 6 for a simple script. Firstly, I created a new console app and was immediately confused. No main method, with no write up in the documentation to using CLI arguments (I need to pass two target path arguments). I found a overflow post regarding how to access arguments through the System.Environment class. So I moved on.

    [Question]

    In .NET Core 5 console apps I had no problem running compiled executables with arguments through the CLI. But when I published my code and ran it through the command line I got the following output (see output) with the strange line "program cannot run in DOS mode". Interestingly enough, it still reads one of ini files, but when I run through powershell it reads the other ini. This is very strange behavior to me. Should I just downgrade back to .NET Core 5 or try and understand what's happening? Is it the fact that I am reading INI's ? (unfortunately I have no choice as its a legacy project). Any help is appreciated.

    [Code]

    1using System.IO;
    2//get command line arguments
    3try
    4{
    5    string stationIniPath = Environment.GetCommandLineArgs()[0];
    6    string equipmentIniPath = Environment.GetCommandLineArgs()[1];
    7    Console.WriteLine(&quot;- Reading INI data -&quot;);
    8    if(stationIniPath != null &amp;&amp; equipmentIniPath != null){
    9        string[] stationINI = System.IO.File.ReadAllLines(stationIniPath);
    10        string[] equipmentINI = System.IO.File.ReadAllLines(equipmentIniPath);
    11        foreach(string station in stationINI)
    12        {
    13            Console.WriteLine(station);
    14        }
    15        foreach(string equipment in equipmentINI)
    16        {
    17            Console.WriteLine(equipment);
    18        }
    19    }
    20    else
    21    {
    22        throw new Exception(&quot;Need to specify command line arguments&quot;);
    23    }
    24
    25
    26}
    27catch (Exception e)
    28{
    29    Console.WriteLine(&quot;You must specify arguments [0] Station INI Path and [1] Equipment INI path :   &quot; + e.Message);
    30}
    31

    [Output When Ran using Powershell & || CMD] CLI output

    ANSWER

    Answered 2022-Jan-11 at 21:27

    Environment.GetCommandLineArgs() always has process file name as the first element. You should start from index 1.

    Source https://stackoverflow.com/questions/70673617

    QUESTION

    How to use Windows.Storage.Streams.DataWriter with PowerShell

    Asked 2022-Jan-10 at 21:53

    I am trying to use the method DetachBuffer() of Windows.Storage.Streams.DataWriter but PowerShell only recognizes the IBuffer that it supposed to return as __ComObject. I have used other WinRT objects successfully, but this one is giving me trouble.

    1[void][Windows.Storage.Streams.DataWriter, Windows.Storage.Streams, ContentType = WindowsRuntime]
    2$dataWriter = [Windows.Storage.Streams.DataWriter]::new()
    3$dataWriter.WriteByte(0x01)
    4$buffer = $dataWriter.DetachBuffer()
    5$buffer
    6
    7System.__ComObject
    8
    9$buffer | Get-Member
    10
    11
    12   TypeName: System.__ComObject
    13
    14Name                      MemberType Definition
    15----                      ---------- ----------
    16CreateObjRef              Method     System.Runtime.Remoting.ObjRef CreateObjRef(type requestedType)
    17Equals                    Method     bool Equals(System.Object obj)
    18GetHashCode               Method     int GetHashCode()
    19GetLifetimeService        Method     System.Object GetLifetimeService()
    20GetType                   Method     type GetType()
    21InitializeLifetimeService Method     System.Object InitializeLifetimeService()
    22ToString                  Method     string ToString() 
    23

    I am assuming that I need to "import" some WinRT class that DetachBuffer() is actually returning, but I have no clue what it is other than it implements IBuffer interface.

    ANSWER

    Answered 2022-Jan-10 at 21:53

    In my search for an answer to a similar problem (IInputStream Interface) I came upon this Reddit thread that gets the content of IBuffer as follows:

    1[void][Windows.Storage.Streams.DataWriter, Windows.Storage.Streams, ContentType = WindowsRuntime]
    2$dataWriter = [Windows.Storage.Streams.DataWriter]::new()
    3$dataWriter.WriteByte(0x01)
    4$buffer = $dataWriter.DetachBuffer()
    5$buffer
    6
    7System.__ComObject
    8
    9$buffer | Get-Member
    10
    11
    12   TypeName: System.__ComObject
    13
    14Name                      MemberType Definition
    15----                      ---------- ----------
    16CreateObjRef              Method     System.Runtime.Remoting.ObjRef CreateObjRef(type requestedType)
    17Equals                    Method     bool Equals(System.Object obj)
    18GetHashCode               Method     int GetHashCode()
    19GetLifetimeService        Method     System.Object GetLifetimeService()
    20GetType                   Method     type GetType()
    21InitializeLifetimeService Method     System.Object InitializeLifetimeService()
    22ToString                  Method     string ToString() 
    23[System.Runtime.InteropServices.WindowsRuntime.WindowsRuntimeBufferExtensions].
    24GetMethod(
    25    'ToArray',
    26    [type[]]@([Windows.Storage.Streams.IBuffer])).
    27Invoke($null, @($buffer))
    28

    From your question it is unclear what you want to achieve, but let me know if this helps. If not, please amend the question so that it is clear what you want to do with the IBuffer.

    As the commenter below correctly adds: PowerShell does not work with WinRT object that have no concrete type (in this case IBuffer Interface). I've been using .Invoke() to work around that, but in my very limited experience it's a hassle and not always gives you what you really need.

    Source https://stackoverflow.com/questions/70545839

    QUESTION

    BTSKTask AddResource - How to raise an error in case the command fails

    Asked 2021-Dec-30 at 00:31

    We are using the following command to deploy BizTalk assemblies via PowerShell:

    1BTSTask AddResource /ApplicationName:$App /Type:$BizTalkAssemblyType /Overwrite /Source:$Source /Options:GacOnAdd,GacOnInstall,GacOnImport
    2

    See: https://docs.microsoft.com/en-us/biztalk/core/addresource-command-biztalk-assembly

    There are certain reasons this command can fail, e.g. an orchestration is not in the unenlisted state or one or more instances of the orchestration exists.

    In this case the command does not raise an error so the script continues with an output like

    1BTSTask AddResource /ApplicationName:$App /Type:$BizTalkAssemblyType /Overwrite /Source:$Source /Options:GacOnAdd,GacOnInstall,GacOnImport
    2Command failed with 1 errors, 0 warnings.
    3

    Because in this situation the assembly does not get deployed we would like to fail the PowerShell script e.g. by raising an error. How to achieve this?

    ANSWER

    Answered 2021-Dec-30 at 00:31

    You need to capture the output and check it for the failure, or rather, check for success and fail if it doesn't.

    1BTSTask AddResource /ApplicationName:$App /Type:$BizTalkAssemblyType /Overwrite /Source:$Source /Options:GacOnAdd,GacOnInstall,GacOnImport
    2Command failed with 1 errors, 0 warnings.
    3[array] $cmdOutput = BTSTask AddResource /ApplicationName:$App /Type:$BizTalkAssemblyType /Overwrite /Source:$Source /Options:&quot;GacOnAdd,GacOnInstall,GacOnImport&quot;
    4
    5$line = $cmdOutput.Count-2
    6
    7
    8if ( $cmdOutput[$line] -eq &quot;Command succeeded with 0 errors, 0 warnings.&quot;)
    9{
    10    Write-Output &quot;Deploy suceeded&quot;
    11}
    12else
    13{
    14    Throw &quot;Deploy failed $cmdOutput&quot; 
    15}
    16

    Source https://stackoverflow.com/questions/70517419

    QUESTION

    How can I suppress or resolve &quot;info: detecting host provider for...&quot; in Git?

    Asked 2021-Nov-25 at 13:09

    I'm getting the following output when executing a fetch / pull via a powershell script:

    info: detecting host provider for '[devops site address]'...

    Normally, this wouldn't be an issue, however, Azure DevOps sees this output as an error and labels the release stage as such. Is there a way I can either suppress this output, or resolve it via GIT?

    The remote location for the repository is an on-prem version of DevOps.

    Thanks!

    ANSWER

    Answered 2021-Nov-25 at 13:09

    This comes indeed from the GCM used by Git.
    You can either downgrade to Git 2.32, or wait for the recently released Git-Credential-Manager-Core v2.0.603, which does remove those messages.

    Said release is not yet packaged with the latest Git for Windows, like the recent 2.34.0, but expect it in 2.34.1.

    A set GCM_PROVIDER=generic could help too.


    Update Nov. 25th, 2021: Git for Windows 2.34.1 has been released, and it does include Git Credential Manager Core v2.0.605.12951.

    That GCM 2.0.605 includes "Remove noisy messages during auto-detection" (#492, #494).

    Source https://stackoverflow.com/questions/69681452

    QUESTION

    Why does nvidia-smi return &quot;GPU access blocked by the operating system&quot; in WSL2 under Windows 10 21H2

    Asked 2021-Nov-18 at 19:20
    Installing CUDA on WSL2

    I've installed Windows 10 21H2 on both my desktop (AMD 5950X system with RTX3080) and my laptop (Dell XPS 9560 with i7-7700HQ and GTX1050) following the instructions on https://docs.nvidia.com/cuda/wsl-user-guide/index.html:

    1. Install CUDA-capable driver in Windows
    2. Update WSL2 kernel in PowerShell: wsl --update
    3. Install CUDA toolkit in Ubuntu 20.04 in WSL2 (Note that you don't install a CUDA driver in WSL2, the instructions explicitly tell that the CUDA driver should not be installed.):
    1$ wget https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-wsl-ubuntu.pin
    2$ sudo mv cuda-wsl-ubuntu.pin /etc/apt/preferences.d/cuda-repository-pin-600
    3$ wget https://developer.download.nvidia.com/compute/cuda/11.4.0/local_installers/cuda-repo-wsl-ubuntu-11-4-local_11.4.0-1_amd64.deb
    4$ sudo dpkg -i cuda-repo-wsl-ubuntu-11-4-local_11.4.0-1_amd64.deb
    5$ sudo apt-key add /var/cuda-repo-wsl-ubuntu-11-4-local/7fa2af80.pub
    6$ sudo apt-get update
    7$ sudo apt-get -y install cuda
    8
    The Error

    On my desktop nvidia-smi and CUDA samples are working fine in WSL2. But on my laptop running nvidia-smi in WSL2 returns:

    1$ wget https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-wsl-ubuntu.pin
    2$ sudo mv cuda-wsl-ubuntu.pin /etc/apt/preferences.d/cuda-repository-pin-600
    3$ wget https://developer.download.nvidia.com/compute/cuda/11.4.0/local_installers/cuda-repo-wsl-ubuntu-11-4-local_11.4.0-1_amd64.deb
    4$ sudo dpkg -i cuda-repo-wsl-ubuntu-11-4-local_11.4.0-1_amd64.deb
    5$ sudo apt-key add /var/cuda-repo-wsl-ubuntu-11-4-local/7fa2af80.pub
    6$ sudo apt-get update
    7$ sudo apt-get -y install cuda
    8$ nvidia-smi
    9Failed to initialize NVML: GPU access blocked by the operating system
    10Failed to properly shut down NVML: GPU access blocked by the operating system
    11

    I'm aware my laptop has NVIDIA Optimus with both Intel IGP and NVIDIA GTX1050, but CUDA is working fine in Windows. Only not in WSL2. But I also could not find any information that CUDA is not supposed to work in WSL2 for Optimus systems.

    What I've tried

    I've tried the following mitigations, but the error remains:

    • reinstalling the Windows CUDA driver again and rebooting
    • Making the GTX1050 the preferred GPU in global settings in the NVIDIA control panel
    • Making the GTX1050 the default physx processor
    • Following the same steps for a fresh Ubuntu 18.04 in WSL2
    The question

    Is this a CUDA WSL2 bug? Or does CUDA simply not work with Optimus? Or how can I fix or further debug this?

    More details

    I've compared running nvidia-smi.exe in Windows powershell between my desktop and laptop, and they both return the same software versions:

    1$ wget https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-wsl-ubuntu.pin
    2$ sudo mv cuda-wsl-ubuntu.pin /etc/apt/preferences.d/cuda-repository-pin-600
    3$ wget https://developer.download.nvidia.com/compute/cuda/11.4.0/local_installers/cuda-repo-wsl-ubuntu-11-4-local_11.4.0-1_amd64.deb
    4$ sudo dpkg -i cuda-repo-wsl-ubuntu-11-4-local_11.4.0-1_amd64.deb
    5$ sudo apt-key add /var/cuda-repo-wsl-ubuntu-11-4-local/7fa2af80.pub
    6$ sudo apt-get update
    7$ sudo apt-get -y install cuda
    8$ nvidia-smi
    9Failed to initialize NVML: GPU access blocked by the operating system
    10Failed to properly shut down NVML: GPU access blocked by the operating system
    11PS C:\WINDOWS\system32&gt; nvidia-smi
    12Wed Nov 17 21:46:50 2021
    13+-----------------------------------------------------------------------------+
    14| NVIDIA-SMI 510.06       Driver Version: 510.06       CUDA Version: 11.6     |
    15|-------------------------------+----------------------+----------------------+
    16| GPU  Name            TCC/WDDM | Bus-Id        Disp.A | Volatile Uncorr. ECC |
    17| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
    18|                               |                      |               MIG M. |
    19|===============================+======================+======================|
    20|   0  NVIDIA GeForce ... WDDM  | 00000000:01:00.0 Off |                  N/A |
    21| N/A   44C    P8    N/A /  N/A |     75MiB /  4096MiB |      1%      Default |
    22|                               |                      |                  N/A |
    23+-------------------------------+----------------------+----------------------+
    24
    25+-----------------------------------------------------------------------------+
    26| Processes:                                                                  |
    27|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
    28|        ID   ID                                                   Usage      |
    29|=============================================================================|
    30|  No running processes found                                                 |
    31+-----------------------------------------------------------------------------+
    32
    Even more details

    The full nvidia-smi.exe -q on my laptop in Windows Powershell returns the following information about my laptop's GPU:

    1$ wget https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-wsl-ubuntu.pin
    2$ sudo mv cuda-wsl-ubuntu.pin /etc/apt/preferences.d/cuda-repository-pin-600
    3$ wget https://developer.download.nvidia.com/compute/cuda/11.4.0/local_installers/cuda-repo-wsl-ubuntu-11-4-local_11.4.0-1_amd64.deb
    4$ sudo dpkg -i cuda-repo-wsl-ubuntu-11-4-local_11.4.0-1_amd64.deb
    5$ sudo apt-key add /var/cuda-repo-wsl-ubuntu-11-4-local/7fa2af80.pub
    6$ sudo apt-get update
    7$ sudo apt-get -y install cuda
    8$ nvidia-smi
    9Failed to initialize NVML: GPU access blocked by the operating system
    10Failed to properly shut down NVML: GPU access blocked by the operating system
    11PS C:\WINDOWS\system32&gt; nvidia-smi
    12Wed Nov 17 21:46:50 2021
    13+-----------------------------------------------------------------------------+
    14| NVIDIA-SMI 510.06       Driver Version: 510.06       CUDA Version: 11.6     |
    15|-------------------------------+----------------------+----------------------+
    16| GPU  Name            TCC/WDDM | Bus-Id        Disp.A | Volatile Uncorr. ECC |
    17| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
    18|                               |                      |               MIG M. |
    19|===============================+======================+======================|
    20|   0  NVIDIA GeForce ... WDDM  | 00000000:01:00.0 Off |                  N/A |
    21| N/A   44C    P8    N/A /  N/A |     75MiB /  4096MiB |      1%      Default |
    22|                               |                      |                  N/A |
    23+-------------------------------+----------------------+----------------------+
    24
    25+-----------------------------------------------------------------------------+
    26| Processes:                                                                  |
    27|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
    28|        ID   ID                                                   Usage      |
    29|=============================================================================|
    30|  No running processes found                                                 |
    31+-----------------------------------------------------------------------------+
    32PS C:\WINDOWS\system32&gt; nvidia-smi -q
    33
    34==============NVSMI LOG==============
    35
    36Timestamp                                 : Wed Nov 17 21:48:19 2021
    37Driver Version                            : 510.06
    38CUDA Version                              : 11.6
    39
    40Attached GPUs                             : 1
    41GPU 00000000:01:00.0
    42    Product Name                          : NVIDIA GeForce GTX 1050
    43    Product Brand                         : GeForce
    44    Product Architecture                  : Pascal
    45    Display Mode                          : Disabled
    46    Display Active                        : Disabled
    47    Persistence Mode                      : N/A
    48    MIG Mode
    49        Current                           : N/A
    50        Pending                           : N/A
    51    Accounting Mode                       : Disabled
    52    Accounting Mode Buffer Size           : 4000
    53    Driver Model
    54        Current                           : WDDM
    55        Pending                           : WDDM
    56    Serial Number                         : N/A
    57    GPU UUID                              : GPU-7645072f-7516-5488-316d-6277d101f64e
    58    Minor Number                          : N/A
    59    VBIOS Version                         : 86.07.3e.00.1c
    60    MultiGPU Board                        : No
    61    Board ID                              : 0x100
    62    GPU Part Number                       : N/A
    63    Module ID                             : 0
    64    Inforom Version
    65        Image Version                     : N/A
    66        OEM Object                        : N/A
    67        ECC Object                        : N/A
    68        Power Management Object           : N/A
    69    GPU Operation Mode
    70        Current                           : N/A
    71        Pending                           : N/A
    72    GSP Firmware Version                  : N/A
    73    GPU Virtualization Mode
    74        Virtualization Mode               : None
    75        Host VGPU Mode                    : N/A
    76    IBMNPU
    77        Relaxed Ordering Mode             : N/A
    78    PCI
    79        Bus                               : 0x01
    80        Device                            : 0x00
    81        Domain                            : 0x0000
    82        Device Id                         : 0x1C8D10DE
    83        Bus Id                            : 00000000:01:00.0
    84        Sub System Id                     : 0x07BE1028
    85        GPU Link Info
    86            PCIe Generation
    87                Max                       : 3
    88                Current                   : 3
    89            Link Width
    90                Max                       : 16x
    91                Current                   : 16x
    92        Bridge Chip
    93            Type                          : N/A
    94            Firmware                      : N/A
    95        Replays Since Reset               : 0
    96        Replay Number Rollovers           : 0
    97        Tx Throughput                     : 0 KB/s
    98        Rx Throughput                     : 0 KB/s
    99    Fan Speed                             : N/A
    100    Performance State                     : P8
    101    Clocks Throttle Reasons
    102        Idle                              : Active
    103        Applications Clocks Setting       : Not Active
    104        SW Power Cap                      : Not Active
    105        HW Slowdown                       : Not Active
    106            HW Thermal Slowdown           : Not Active
    107            HW Power Brake Slowdown       : Not Active
    108        Sync Boost                        : Not Active
    109        SW Thermal Slowdown               : Not Active
    110        Display Clock Setting             : Not Active
    111    FB Memory Usage
    112        Total                             : 4096 MiB
    113        Used                              : 75 MiB
    114        Free                              : 4021 MiB
    115    BAR1 Memory Usage
    116        Total                             : 256 MiB
    117        Used                              : 2 MiB
    118        Free                              : 254 MiB
    119    Compute Mode                          : Default
    120    Utilization
    121        Gpu                               : 0 %
    122        Memory                            : 0 %
    123        Encoder                           : 0 %
    124        Decoder                           : 0 %
    125    Encoder Stats
    126        Active Sessions                   : 0
    127        Average FPS                       : 0
    128        Average Latency                   : 0
    129    FBC Stats
    130        Active Sessions                   : 0
    131        Average FPS                       : 0
    132        Average Latency                   : 0
    133    Ecc Mode
    134        Current                           : N/A
    135        Pending                           : N/A
    136    ECC Errors
    137        Volatile
    138            Single Bit
    139                Device Memory             : N/A
    140                Register File             : N/A
    141                L1 Cache                  : N/A
    142                L2 Cache                  : N/A
    143                Texture Memory            : N/A
    144                Texture Shared            : N/A
    145                CBU                       : N/A
    146                Total                     : N/A
    147            Double Bit
    148                Device Memory             : N/A
    149                Register File             : N/A
    150                L1 Cache                  : N/A
    151                L2 Cache                  : N/A
    152                Texture Memory            : N/A
    153                Texture Shared            : N/A
    154                CBU                       : N/A
    155                Total                     : N/A
    156        Aggregate
    157            Single Bit
    158                Device Memory             : N/A
    159                Register File             : N/A
    160                L1 Cache                  : N/A
    161                L2 Cache                  : N/A
    162                Texture Memory            : N/A
    163                Texture Shared            : N/A
    164                CBU                       : N/A
    165                Total                     : N/A
    166            Double Bit
    167                Device Memory             : N/A
    168                Register File             : N/A
    169                L1 Cache                  : N/A
    170                L2 Cache                  : N/A
    171                Texture Memory            : N/A
    172                Texture Shared            : N/A
    173                CBU                       : N/A
    174                Total                     : N/A
    175    Retired Pages
    176        Single Bit ECC                    : N/A
    177        Double Bit ECC                    : N/A
    178        Pending Page Blacklist            : N/A
    179    Remapped Rows                         : N/A
    180    Temperature
    181        GPU Current Temp                  : 40 C
    182        GPU Shutdown Temp                 : 102 C
    183        GPU Slowdown Temp                 : 97 C
    184        GPU Max Operating Temp            : 78 C
    185        GPU Target Temperature            : N/A
    186        Memory Current Temp               : N/A
    187        Memory Max Operating Temp         : N/A
    188    Power Readings
    189        Power Management                  : N/A
    190        Power Draw                        : N/A
    191        Power Limit                       : N/A
    192        Default Power Limit               : N/A
    193        Enforced Power Limit              : N/A
    194        Min Power Limit                   : N/A
    195        Max Power Limit                   : N/A
    196    Clocks
    197        Graphics                          : 0 MHz
    198        SM                                : 0 MHz
    199        Memory                            : 405 MHz
    200        Video                             : 0 MHz
    201    Applications Clocks
    202        Graphics                          : N/A
    203        Memory                            : N/A
    204    Default Applications Clocks
    205        Graphics                          : N/A
    206        Memory                            : N/A
    207    Max Clocks
    208        Graphics                          : 1911 MHz
    209        SM                                : 1911 MHz
    210        Memory                            : 3504 MHz
    211        Video                             : 1708 MHz
    212    Max Customer Boost Clocks
    213        Graphics                          : N/A
    214    Clock Policy
    215        Auto Boost                        : N/A
    216        Auto Boost Default                : N/A
    217    Voltage
    218        Graphics                          : N/A
    219    Processes                             : None
    220

    ANSWER

    Answered 2021-Nov-18 at 19:20

    Turns out that Windows 10 Update Assistant incorrectly reported it upgraded my OS to 21H2 on my laptop. Checking Windows version by running winver reports that my OS is still 21H1. Of course CUDA in WSL2 will not work in Windows 10 without 21H2.

    After successfully installing 21H2 I can confirm CUDA works with WSL2 even for laptops with Optimus NVIDIA cards.

    Source https://stackoverflow.com/questions/70011494

    Community Discussions contain sources that include Stack Exchange Network

    Tutorials and Learning Resources in PowerShell

    Tutorials and Learning Resources are not available at this moment for PowerShell

    Share this Page

    share link

    Get latest updates on PowerShell