powershell-ise

How to run python interpreter in windows powershell ISE?

隐身守侯 提交于 2019-12-13 19:26:58
问题 According Microsoft, we can't run interactive console like python in it's own powershell ISE console. According to some sources it runs in the background. Can we run the same python interpreter in foreground ? 回答1: When people say it "runs in the background" they mean that when you try to run Python in ISE, it opens a legacy console app which ISE illogically hides (even though it can't bridge your actions to that app). If you run a script which runs and terminates , that's fine, you can do

Powershell: Specify file path as variable

旧巷老猫 提交于 2019-12-13 18:27:03
问题 I am running the following SQL query through a powershell script and need to run the script multiple times against different files. So what I am trying to figure out is how to specify a file path as a variable when I run the script? update [$Db_name].[dbo].[$BatchTable] set [$Db_name].[dbo].[$BatchTable].Wave = 'Wave1.1' from [$Db_name].[dbo].[$BatchTable] inner join OPENROWSET(BULK 'FilePath\file.csv', FORMATFILE= 'E:\import.xml') AS a on ([$Db_name].[dbo].[$BatchTable].Name= a.Name) and ([

Real Time Data With Powershell GUI

喜欢而已 提交于 2019-12-12 17:38:46
问题 I'm struggling here. Using Powershell and GUI, how to automatically refresh data on a form? Example with the script below, how to automatically update the label with the number of process executed by my computer? Add-Type -AssemblyName System.Windows.Forms $Form = New-Object system.Windows.Forms.Form $Form.Text = "Sample Form" $Label = New-Object System.Windows.Forms.Label $Label.Text = "Number of process executed on my computer" $Label.AutoSize = $True $Form.Controls.Add($Label) $Form

Try/catch not working in Powershell console, but works in ISE

谁都会走 提交于 2019-12-12 04:32:07
问题 I have a Powershell script with try / catch parts to write the errors into a logfile. This works perfectly fine in Powershell ISE, but not in the Powershell console. Here's the script: $serverfile = "C:\Serverlist.txt" $Logfile = "C:\Deploy_Log.txt" $startdate= "01/05/2016" $starttime = 13 Set-StrictMode -Version latest $ErrorActionPreference = "Stop" $WarningPreference = "Stop" function LogWrite { param([string]$logstring) Add-Content $Logfile -Value $logstring } function DeployTask { param(

How to store data from foreach function in HTML file in powershell and get Physicall ram

不羁岁月 提交于 2019-12-11 23:57:34
问题 I have written a for each file which stores the BIOS information of the systems in a network and the result is being displayed on my console but I want them to be in a HTML file in an order. Code: $arrComputers = get-Content -Path "C:\Computers.txt" foreach ($strComputer in $arrComputers) { $colItems = get-wmiobject -class "Win32_BIOS" -namespace "root\CIMV2" ` -computername $strComputer foreach ($objItem in $colItems) { write-host "Computer Name: " $strComputer write-host "BIOS Version: "

How to delete lines in a CSV that start with “#” or are blank | PowerShell

≡放荡痞女 提交于 2019-12-11 18:51:36
问题 I have a CSV file that contains nearly 4,000+ lines, with random blank lines and comments starting with "#" throughout. I'm trying to import the CSV file while skipping lines that are blank or start with "#". I've tried this: $csvFile = Import-Csv .\example.csv | Where-Object {$_ -notlike '#*'} | Where-Object {$_ -ne ''} and this does not work. I've also tried: $csvFile = Import-Csv .\example.csv Get-Content $csvFile | Where-Object {$_ -notlike '#*' | Where-Object {$_ -ne ''} | Set-Content

Powershell simulate Keyboard

柔情痞子 提交于 2019-12-11 10:07:45
问题 I have a problem using sendkeys is Powershell. I'm trying to make a script that wil send the keys: shift,w,a,s,d to a game. The code i'm trying is: Add-Type -AssemblyName System.Windows.Forms [System.Windows.Forms.SendKeys]::SendWait(+{w}{a}{s}{d}); But when I use this it just sends "Wasd". It won't change the movement, i can see that this has been send in the in-game console. Is there a way i can simulate the keypresses? It can by done for the left mouse button using this: $signature=@'

Replace blank characters from a file line by line

天大地大妈咪最大 提交于 2019-12-11 09:46:14
问题 I would like to be able to find all blanks from a CSV file and if a blank character is found on a line then should appear on the screen and I should be asked if I want to keep the entire line which contains that white space or remove it. Let's say the directory is C:\Cr\Powershell\test . In there there is one CSV file abc.csv . Tried doing it like this but in PowerShell ISE the $_.PSObject.Properties isn't recognized. $csv = Import-Csv C:\Cr\Powershell\test\*.csv | Foreach-Object { $_

How to ignore warning errors?

纵然是瞬间 提交于 2019-12-11 03:53:18
问题 I have the following PowerShell script. It picks up the NetBIOS name of computers within a given IP address. I'm using a pipe so as to dump the results into a text file. The problem is that if an IP address is not available, a warning is printed. This is the PowerShell script: function Get-ComputerNameByIP { param( $IPAddress = $null ) BEGIN { $prefBackup = $WarningPreference $WarningPreference = 'SilentlyContinue' } PROCESS { if ($IPAddress -and $_) { throw ‘Please use either pipeline or

Powershell debugging event -Action code block

随声附和 提交于 2019-12-10 23:36:26
问题 I have script watching file creation in a specific directory. I'm using Register-ObjectEvent after creating a System.IO.FileSystemWatcher, It works great, but if I set a break point in the -Action code block the IDE generates a: WARNING: Breakpoint Line breakpoint on 'D:\My Stuff\Desktop\scripts\fileWatcher.ps1:15' will not be hit this message happens right after I drop a file into the directory I'm watching and I can see my Write-Host printing out my message right after the above 'warning'.