PowerShell | Mega collection of 500+ useful cross-platform PowerShell scripts | Command Line Interface library
kandi X-RAY | PowerShell Summary
kandi X-RAY | PowerShell Summary
Note: the scripts fully support Unicode I/O. It’s recommended to use a modern console supporting UTF-8 (e.g. Windows Terminal). Scripts for Audio & Voice.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of PowerShell
PowerShell Key Features
PowerShell Examples and Code Snippets
Community Discussions
Trending Discussions on PowerShell
QUESTION
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.
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:27Enabling 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
QUESTION
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:55As 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.
QUESTION
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.
...ANSWER
Answered 2021-Dec-17 at 09:47There 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
QUESTION
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:
...ANSWER
Answered 2022-Feb-07 at 21:09This 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)
- 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
[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).
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
is in effect the same as the following two statements, the first of which (potentially) produces output, the second of which exits the scope:; 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 assigns1
to both variables: statement-internally the assignment value is passed through, but the statement as a whole has no output.
- A hybrid case is the chaining form of a multi-assignment, e.g.
- 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 assigns1
to variable$n
and outputs1
, 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.
- Note that the related
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:
QUESTION
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.
ANSWER
Answered 2022-Jan-15 at 08:50There is an update to mini-css-extract-plugin in version 2.5.0. I temporarily fixed it by adding in package.json
:
QUESTION
[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]
...ANSWER
Answered 2022-Jan-11 at 21:27Environment.GetCommandLineArgs()
always has process file name as the first element. You should start from index 1.
QUESTION
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.
ANSWER
Answered 2022-Jan-10 at 21:53In 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:
QUESTION
We are using the following command to deploy BizTalk assemblies via PowerShell:
...ANSWER
Answered 2021-Dec-30 at 00:31You need to capture the output and check it for the failure, or rather, check for success and fail if it doesn't.
QUESTION
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:09This 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).
QUESTION
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:
- Install CUDA-capable driver in Windows
- Update WSL2 kernel in PowerShell:
wsl --update
- 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.):
ANSWER
Answered 2021-Nov-18 at 19:20Turns 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.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install PowerShell
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page