Powershell 5.1 module manifest practical difference of declaring FunctionsToExport vs CmdletsToExport
Stack Overflow » Powershell
by Avner
1h ago
I understand the difference between functions and cmdlets. This question is about the practical implications of when to declare a function in one or the other group of a powershell manifest file (psd1). FunctionsToExport = @( 'Get-BuildInformation' ) CmdletsToExport @( 'Get-BuildInformation' ) One thing I noticed is that on importing a module, comment based help does not work if the cmdlet is only declared in CmdletsToExport - it has to be declared in FunctionsToExport. Should I be adding to both arrays? What am I getting by adding to CmdletsToExport ..read more
Visit website
VS Code terminal with oh-my-posh is showing strange characters
Stack Overflow » Powershell
by Minamoto Yuki
1h ago
These characters are always showing up on my VS Code terminal. How do I fix it? I was installing Oh-My-Posh, the Powershell looks normal in Windows Terminal. Only in VS Code does the terminal look weird. I have installed and applied the Nerd Fonts. How to fix this, or is there some kind of specific configuration for the VS Code terminal ..read more
Visit website
PowerShell script doesn't work as it does in ISE
Stack Overflow » Powershell
by user23357415
5h ago
I've developed a program in ISE, but don't get the same behavior when running it from the command line (e.g., > .\script.ps1 -ProjectDirectoryPath .\project). Namely, exceptions are not redirected to an error log within try/catch and $Error is empty. # Loop start time $starttime = Get-Date foreach($thing in $things) { Write-Host "comment about $thing..." try { $ErrorActionPreference = "Stop" #does stuff } catch { $_.Exception | Out-File $ProjectDirectoryPath\error.log -Append } } # Print processing sta ..read more
Visit website
Regex stop at space & skip rest of the info in a line
Stack Overflow » Powershell
by Derek B
8h ago
I am working with some data that the last portion of sometimes has additional information than others. When this additional information exists, I need regex to skip it and move on to the next line. So sometimes my data ends like this: LAT:35.7427280 LONG:-86.1315921 GRIDREF:01800S 01600E Other times it ends like this: LAT:35.7427280 LONG:-86.1315921 (There is a lot more before that, but I have removed it for simplicity) In the below code, sometimes "GRIDREF" exists and I just need it to ignore that and move on to the next line. Sometimes it does not exist, in which case I need it to move on to ..read more
Visit website
Powershell replace a string with percentages and quotations
Stack Overflow » Powershell
by Tika9o9
12h ago
I am struggling to get this powershell replace (command in a batch) text to work; @echo off pushd %~dp0 setlocal EnableDelayedExpansion ::enable PS commands in batch set "Ps_Bypass=PowerShell.exe -NoProfile -ExecutionPolicy Bypass -Command" set /p install=Add File1..(y)es (n)o: if "%install%"=="n" %Ps_Bypass% "(gc "files.txt") -replace '%FILE1%="Install File One.zip"', ''" ^| Set-Content files.txt If the user presses no, the entry %FILE1%="Install File One.zip" needs to be blanked from the files.txt, otherwise left leaving a list of chosen files for another program. There are a few other l ..read more
Visit website
Hi All, I am much novice in powershell as well as in excel. Please help me with your expertise skills on comparing two excelsheet columns
Stack Overflow » Powershell
by user12646808
14h ago
I want your help here. First, in the given excel sheet has the following values, in that with the respective of Column A(integer-month) if it find matches compare the values of Column "C" (integer-size) and create a new column next to it show difference. and enter image description here enter image description here Please need your help here, thank you. I want your help here. First, in the given excel sheet has the following values, in that with the respective of Column A(integer-month) if it find matches compare the values of Column "C" (integer-size) and create a new column next to it show d ..read more
Visit website
PowerShell, WPF, DataGrid: Image will not display? [duplicate]
Stack Overflow » Powershell
by Captain_Planet
15h ago
I'm trying to use PowerShell and WPF to write a Datagrid with an image column. But I can't get the image to display for the life of me. I need to display an image "in memory" as opposed to a physical image on disk. Hence i try and convert it in this example: Add-Type -AssemblyName PresentationCore, PresentationFramework, WindowsBase # Function to convert image file to BitmapSource function Convert-ImageFileToBitmapSource { param ( [string] $ImagePath ) # Load the image from file $bitmap = New-Object System.Drawing.Bitmap($ImagePath) # Convert Bitmap to BitmapSou ..read more
Visit website
How do I get the LogicalName from query and store into variables using sqlcmd
Stack Overflow » Powershell
by Nayeer Mahiuddin
21h ago
I wanna create a Powershell script to automatically restore DB backups when I need it. But I'm having some trouble with it because when I restore it I don't restore it to it's original name, usually a different name. And a problem I am facing is getting the logical name from my backup. I got this query that can retrieve the Logical name, but I cannot seem to figure out how to extract that name from the results. $serverName = "MY-PC" $backupFolder = "D:\DatabaseBackup" $userName = "sa" $password = "123" $logicalNameData = "" $logicalNameLog = "" $query = @" DECLARE @Table TABLE ( [Logica ..read more
Visit website
How to Launch MS Paint 3D by Powershell without Passing it to Old MS Paint Application
Stack Overflow » Powershell
by hamflow
23h ago
Apparently Windows (only 10?) installed some troublesome updates that make it impossible to open Paint 3D using old microsoft paint environment. To make things worse, Paint 3D does not have an .exe address to use right click context menu to "open with" images. I searched and apparently the old method to launch paint 3d by powershell was using old ms paint to pass the argument, something like: Start-Process -FilePath "mspaint" -ArgumentList """C:\IMAGE_PATH.jpg /ForceBootstrapPaint3D""" Unfortunately, above code too makes powershell to go to windows store. Does anyone know a method to launch ..read more
Visit website
Powershell - Passing commands to spawned Command Prompt
Stack Overflow » Powershell
by sbagnato
1d ago
I'll try to explain the use case here. I am writing a script to automate the management of remote services. This can easily be done with sc.exe via command prompt. However, this use case is to write the script via Powershell. I currently have the following: Start-Process cmd.exe -ArgumentList "/c runas.exe /netonly /user:$username cmd.exe" The $username variable has already been set, and is in the domain\username format. The above works. It pops up a cmd window prompting to enter the password (it'd be awesome if the full credential could be passed via Get-Credential, including the password ..read more
Visit website

Follow Stack Overflow » Powershell on FeedSpot

Continue with Google
Continue with Apple
OR