New answers tagged

0

I have installed posh-git from here, oh-my-posh3 from here, MesloLGS NF fonts, then Import-Module posh-git Import-Module oh-my-posh Set-PoshPrompt -Theme <path to a given .omp.json file> and it worked perfectly for all json files I tried. E.g. and all 4 powerlevel10k*.omp.json included. It also worked ok with https://github.com/Kudostoy0u/pwsh10k


0

While the accepted answer works and corrects your code, i simply want to show you a solution that would be very easy to use, also in the shell directly Get-ChildItem $ParentFolder | Where-Object { $_.Name -like '*(Beta)*' } | Remove-Item -force or in short: gci $ParentFolder | ? Name -like '*(Beta)*' | del -Force actually, we can make it even shorter, ...


3

If you are trying to match filenames which contains the string (Beta), then you should not use Get-Content. With Get-Content, you are opening the files and looking in their contents/values for the word (Beta) which is failing. You should only test the filename. Your code should be: ForEach ($file in (Get-ChildItem $ParentFolder)){ Write-Verbose "($...


0

You can map a SharePoint folder to a drive letter, with some preparations. Add your SharePoint base URL to "Trusted Sites": Run Internet Options > Security tab > Trusted Sites > Sites. In the Services applet, ensure that the WebClient service is running. You may set it to start automatically. You may now map a drive-letter to the ...


0

You are only applying the ACL change to the folder you specified with $path, to apply the ACL to everything in the folder you need to list each item recursively: $path = "C:\Windows\Installer" $items = Get-ChildItem -Recurse $path # Enables inheritance on all items in folder foreach ($item in $items) { $acl = Get-acl $item.FullName $acl....


0

The way you concatenated the strings resulted in a space after default_folder: ❯ $myfolder = "default_folder" ❯ $file_date = "20210722" ❯ $file_time = "1157" ❯ write-host "$myfolder"_"$file_date"_"$file_time" default_folder _20210722_1157 Try this for your rename argument instead ${myfolder}_${...


0

Here's a bit of an orthogonal answer to this quite-old question. It's not an answer to the question as literally asked, but more about the "spirit" of the question. It's also not an answer that was even possible for years after the question was asked. But now, it may be useful for some subset of folks who come looking for this information (as I ...


0

try this to download the log with Edge $logg = Get-HistoricalSearch -JobId xxxxxx... | select FileUrl & 'C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe' $logg.FileUrl


1

The following helped the poster with his problem: Get-VirtualDisk -FriendlyName "VDisk01" | Get-StoragePool References: Get-StoragePool Get-VirtualDisk


0

I find the solution Ctrl+H Find what: ^(<meta name="description" content=".*"/>)$\s+?^(?=.*^\1$) Replace with: LEAVE EMPTY check Wrap around check Regular expression CHECK . matches newline Replace all


1

Use the PSWindowsUpdate module. The Get-WUHistory cmdlet uses the same windows update api (wua) that you tried in your question, but does some additional magic in the background to make things readable: $history = Get-WUHistory -Last 1000 # Larger than in Settings app, since it includes failed updates $history.Count 62 $history | sort date -desc | ...


1

I have downloaded linux-lite-5.4-64bit.iso and used it with rufus-3.14, and had no problem with Rufus offering to create a boot media that works for both BIOS or UEFI: If this doesn't work for you, download my versions and try again. You could also try the Universal USB Installer, but Rufus should have worked.


0

WSL actually does not understand Windows paths, because it is not merely "Linux commands on Windows" – it is Linux commands on Linux running on Windows. (Still true even for WSL1 even though Windows emulates the Linux kernel.) So they only recognize the Linux-like paths that WSL provides them. (I don't know whether WSL provides direct access to ...


1

Why the need for | Resolve-Path |? You need to append switch -File to Get-ChildItem so you are not retrieving DirectoryInfo objects together with FileInfo objects. Then use the .FullName property on the -Path parameter (which is the first positional parameter that expects a string array) See Copy-Item Depending on how large the music collection is, this may ...


-1

If your browser or something still uses the old name for your webcam: I figured it out. Say your webcam is called "VisualBox HD Webcam" - that was my case, someone is cheating on an online exam, lol! - and you want it to be just "HD Webcam". What you need to do is open Registry Editor and search for "VisualBox HD Webcam", and ...


0

Setting -Container:$false will omit the directory structure: Copy-Item -Path C:\temp\tree -Filter *.txt -Recurse -Container:$false Docs: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/copy-item?view=powershell-7.1#example-12--recursively-copy-files-from-a-folder-tree-into-the-current-folder


0

I knew it was advised against (partly due to this blog post: http://rabexc.org/posts/pitfalls-of-ssh-agents) - which is what made me get Keychain for Ubuntu. In light of this argument I must warn you against using ssh-agent from the PowerShell port of openssh as it silently uses ondisk storage of your keys in the Registry. See my own question (and answer) ...


1

Do it this way: Create a desktop icon for powershell "C:\path\script.ps1" Right-click the icon and select Properties Click Advanced Click "Run as administrator" Click OK.


0

Since RSS feeds are straightforward XML, there are command line tools, but you'll have to write a domain-specific language to tell them which element from the XML document to retrieve. Not hard, but a new language to learn. I don't know in which language your file manager is written, but I'd honestly just look for "XML parser {languagename}" on ...


3

Don't uninstall any of them. The four "Windows PowerShell" entries are distributed as part of Windows 10. The two marked "ISE" provide a minimal script editor-plus-execution-console; the two marked "(x86)" are for a 32-bit environment instead of a 64-bit environment. Microsoft assumes that these PowerShells will be available for ...


0

I have no idea why but it works now. The command is the same as far as I can tell?? I added the complete path, I cant understand why that would be any better than a placeholder but whatever, and the name of the .exe that didnt work. The only thing that changed is that I edited the code of the parser and recompiled it. It must be that PowerShell cant run an ...


4

cmd and powershell are shells and have nothing to do with the scrolling of vi, which is related to the terminal. Just like in Unix where shells like bash, fish or zsh must be run inside a terminal like xterm or gnome-terminal, both of those Windows shells must be connected to a terminal to work, and the default terminal in older Windows is conhost.exe. That'...


0

Since these scripts are being run manually, a workaround is: Instead of directly opening in the FTP, open the generated CSV in notepad/text editor on your local system. Copy the entire contents and paste the same in the file on the FTP software The new file doesn't have the extra spaces. This is a rudimentary but assured way of getting this done.


0

You need to define the task as "Run only when user is logged on" so it can work on the user's mapped drive. The option of "Run whether user is logged on or not" is to be avoided, and also "Run with highest privilege". The problem is that powershell.exe is a console program, so will create a console window when executed. Using -...


0

A kind user from another forum pointed me to this article and I am gonna share it here and in turn answer my own question as there is not much information on this subject as it is. Here is the articlehere it goes into allot more detail about how windows manages libraries and how it stores its setting files. The examples uses a tool called SLUtil.exe commands ...


0

Per Albin's answer: Make a setResolution.ps1 file with the following contents (src): Function Set-ScreenResolution { <# .Synopsis Sets the Screen Resolution of the primary monitor .Description Uses Pinvoke and ChangeDisplaySettings Win32API to make the change .Example Set-ScreenResolution -Width 1024 -Height 768 ...


0

See my answer here for information on how to adjust the power mode / power slider programmatically using C#. https://stackoverflow.com/a/68318696/4647297 I created a command-line program which can be used to set the power mode, and it can be found at https://github.com/AaronKelley/PowerMode.


-1

After I remove the Windows Appx package with the above Remove-AppxPackage commands - I run the FREE version of CCleaner to uninstall any remaining apps. Some Windows 8, 8.1 and 10 default apps have no uninstall option whatsoever. Maps for example, is built in. This is where CCleaner can help. CCleaner makes managing apps easy by listing them all in one place ...


0

I've got the same problem, but in the context of trying to sysprep a System which was already running for a few months. I am running Windows 10 20H2 (19042.1052) I think my problem was that the user which it was installed for did not exist anymore (I've deleted all users before) and Get-AppxPackage showed a very weired username: S-1-5-21-350941.... (followed ...


0

You could make the command a one-liner: start ((gwmi win32_volume -f 'label=''USB_NAME_HERE''').name + "image.png" ) Also, it appears you no longer need to use Start/Start-Process, just use the image name:


0

You are not refreshing anything, you are in effect removing the s: disk with the command subst s: /D. Any Explorer instance that was showing the s: disk will terminate immediately. Your second subst command creates a new disk, and Explorer knows immediately about it. But this is a new disk that has now to be explored anew.


0

Using MSYS and MinGW Copy the produced binary nano.exe to your environment. You can get this: From source I installed MYSYS with MinGW and was able to: $ pacman -S tar gcc ncurses ncurses-devel $ f='nano-5.8' # Change this line for a different v5 version $ curl --proto '=https' --tlsv1.2 -sSf 'https://www.nano-editor.org/dist/v5/'"$f"'.tar.xz' $ ...


0

Nope; that modal dialog is programmed in the BitLocker management code. Outside of writing your own, you can write your code and send it to Show-Command for a GUI, for a user to input stuff. A folder/network share, is not a drive, regardless of the drive mapping on a user's machine. It's just a pointer. Bitlocker is the full drive or noting. BitLocker means ...


1

Here are some ways to do that. basically you just need to expand the path property. PS C:\WINDOWS\system32> $PWD Path ---- C:\WINDOWS\system32 PS C:\WINDOWS\system32> $PWD.Path C:\WINDOWS\system32 PS C:\WINDOWS\system32> $PWD | select -Expand Path C:\WINDOWS\system32 PS C:\WINDOWS\system32> (get-location).path C:\WINDOWS\system32


2

Window store apps are started via URLs not via the exe file. This is how you also open web sites. The below command is a batch file that list all URL schemes on your computer including internet one. They are known as protocol handlers. Because it sorts it, it takes several minutes to run. @For /f "tokens=1* delims=" %%A in ('reg query HKCR /f "...


0

To open the document from the client is as simple as executing \\computer\share-name\folder\document or perhaps word \\computer\share-name\folder\document (or another editor or viewer). From the server to cause the client to open the document is impossible.


0

You just need to test the name to see if it contains the "-" character. Use Where-Object (alias: where or ?): $RootPath = "e:\folder\" Get-ChildItem -Path $RootPath -Directory -Recurse -Depth 0 | Where-Object Name -match '-' | Rename-Item -NewName { $_.Name -replace '-','_' } But ...-Recurse -Depth 0... is equivalent to no recursion, ...


0

After updating to the latest version of powershell, the issue was solved.


0

Make sure PowerShell uses UTF-8 when communicating with external programs. (The built-in cmdlets already default to UTF-8.) This requires setting [console]::InputEncoding and [console]::OutputEncoding to UTF-8. https://github.com/PowerShell/PowerShell/issues/7233 https://stackoverflow.com/q/49476326 On my Windows 10 system, PowerShell uses Code Page 437 by ...


0

Continuing from my comment. As we all know, slmgr is a .vbs that expect specific input, as defined in the MS Docs on that VBS script. That VBS file simply calls: SoftwareLicensingService and SoftwareLicensingProduct WMI classes, which means you can code this out yourself. For example: function Install-LicenseFile ($FilePath) { $SoftwareLicensingService=...


0

Try with the -Include parameter on Get-ChildItem, which can take an array of names to 'filter' on. That way you don't need the Where-Object clause. Also, there is no need for the ForEach-Object loop (alias %), because Remove-Item can work on the piped results straight away: $path = 'd:\folder' Get-ChildItem $path -Recurse -Force -Directory -Include 'Temp', '...


1

(Continuing from my comment) These are two completely separate things: > type test.ps1 Write-Host testing > echo %ERRORLEVEL% 0 This is just using Get-Content (if you were in the PowerShell console, not cmd.exe) to display the text in the script: thus command being run here is Get-Content, not your script code unless you are doing this at a cmd ...


1

The following command worked like a charm $cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 'C:\path\to\mycert.cer' $thumbprint = $cert.Thumbprint Question: Any idea if possible to use .\mycert.cer for the file path, instead of the exact long path? In this script $certPath = 'C:\DirSync\cert.cer' $certPath $cert = New-Object -...


0

Answer from another section: Get-Module -Name VMware* -ListAvailable | Import-Module -Force Connect-ViServer -Server [SERVERNAME] -Credential (Get-Credential) $ExportTo = ".\rightSizingFilter3.csv" $VMs = Get-Cluster -Name [CLUSTERNAME] | Get-VM foreach ($VM in $VMs) { If ( ((Get-Tagassignment $VM).Tag.Name -notcontains "testtag") ) ...


0

I got it to work from the snippet below: $RS = foreach ($VM in $VMs){ If (((Get-Tagassignment $VM).Tag.Name -notcontains "testtag")){ Write-Output $VM } } $RS | Out-file $exportto -Append


Top 50 recent answers are included