Launch Elevated CMD.exe from Powershell

Note: SomeShinyObject came up with the fundamentals of the approach in his answer, but his parameter-passing technique is not robust (update: since corrected) – do not use script blocks in lieu of strings – see bottom. -Verb RunAs is what makes Start-Process launch a process elevated. However, -Verb RunAs cannot be combined with the -Credential … Read more

Find numbers after specific text in a string with RegEx

Try this expression: “Error importing row no\. (\d+):” DEMO Here you need to understand the quantifiers and escaped sequences: . any character; as you want only numbers, use \d; if you meant the period character you must escape it with a backslash (\.) ? Zero or one character; this isn’t what do you want, as … Read more

Loading Assemblies from NuGet Packages

crownedjitter’s helpful answer is a good starting point, and Travis himself has provided additional pointers in comments, but let me try to summarize as of Windows PowerShell v5.1 / PowerShell [Core] 7.1: Update: The original answer, reprinted in the section after this one, contains some useful general pointers, plus a link to the feature suggestion … Read more

Using Get-ChildItem -Exclude or -Include returns nothing

To summarize and complement gravity’s and Brian Reynolds’s helpful answers: There are two distinct problems with your approach: Targeting C: probably doesn’t (always) do what you want, because C: refers to whatever happens to be the current location (working dir.) on drive C: at the moment. To target the root folder of drive C:, you … Read more

How do I pass a local variable to a remote `Invoke-Command`? [duplicate]

To complement briantist’s helpful answer: The script block passed to Invoke-Command is (as intended) executed on the remote machine, using the remote machine’s variables by default. Thus, in order to use a local variable’s value,[1] extra steps are needed (to put it differently: inside a script block executed remotely, you cannot just refer to local … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)