powershell-ise

PowerShell ISE: how to run new PowerShell version

那年仲夏 提交于 2019-12-10 02:35:06
问题 How can I get PowerShell ISE to work with PowerShell 6.0. Currently, it has 4.0. This server has PowerShell 4.0 installed and I installed PowerShell 6.0 with PowerShell-6.1.0-win-x64.msi from this link: https://github.com/PowerShell/PowerShell/releases The files now exist in C:\Program Files\PowerShell\6. However, ISE still shows 4.0, but I need it to run 6.0 $PSVersionTable.psversion Major Minor Build Revision 4 0 -1 -1 回答1: PowerShell has 3 executables... Windows only... PowerShell_ISE.exe

Powershell argument passing to function seemingly not working

▼魔方 西西 提交于 2019-12-08 15:41:33
问题 I sense that I am doing something silly, but here is the issue: Function getPropertyOfFile($a, $b, $c) { $a.GetDetailsOf($b, $c) } If I pass $a, $b, $c variables that are appropriate to the function, it fails saying that "Method invocation failed because [System.Object[]] doesn't contain a method named 'GetDetailsOf'." However, if I directly replace $a, $b, $c with the arguments that I was passing, and then try to run that, it works fine. What the heck is going on? Note: I am using powershell

Powershell datagridview cell click event

我是研究僧i 提交于 2019-12-08 09:45:29
问题 I have a powershell script in that script i am using datagridview. My script is working fine. All looks ok to me. My issue is i want to get the first column value of selected row. To fulfill this i need to add event (cell click/cell content click/cell mouse click). I am not able to figure it out. How to add event. Can somebody please advise me on this? $datagridview1_CellMouseClick = [System.Windows.Forms.DataGridViewCellEventHandler]{ write-host $_.RowIndex # This displays the row number

Debug-Job :The job cannot be debugged because the host debugger mode is set to None or Default

杀马特。学长 韩版系。学妹 提交于 2019-12-08 05:57:23
问题 I created a sample powershell project with a Script.ps1 file and a Modules\Script1\Script1.psm1 file. the module file.. # Script1.psm1 function Get-Greeting{ Start-Sleep -Seconds 10 Write-Host "hello from foo"; } and the script file.. # Script1.ps1 if(-not(Get-Module -Name "Script1")){ Import-Module .\Modules\Script1 } if(Get-Module -Name "Script1"){ Remove-Module Script1; Import-Module .\Modules\Script1; } Get-Greeting # output: hello from foo $ajob = Start-Job -ScriptBlock { Get-Greeting }

Debug-Job :The job cannot be debugged because the host debugger mode is set to None or Default

杀马特。学长 韩版系。学妹 提交于 2019-12-08 05:29:31
I created a sample powershell project with a Script.ps1 file and a Modules\Script1\Script1.psm1 file. the module file.. # Script1.psm1 function Get-Greeting{ Start-Sleep -Seconds 10 Write-Host "hello from foo"; } and the script file.. # Script1.ps1 if(-not(Get-Module -Name "Script1")){ Import-Module .\Modules\Script1 } if(Get-Module -Name "Script1"){ Remove-Module Script1; Import-Module .\Modules\Script1; } Get-Greeting # output: hello from foo $ajob = Start-Job -ScriptBlock { Get-Greeting } -InitializationScript { if(-not(Get-Module -Name "Script1")){ Import-Module 'C:\Users\suyashs\Documents

Multiple Actions for one Outlook rule in Powershell

帅比萌擦擦* 提交于 2019-12-07 22:17:24
问题 I have a question about Outlook Rules in Powershell. I wrote some code that successfully stores any incoming e-mail from a certain sender to the deleted-items folder. I did this because when the mails enter the junk folder, the junk folder still has the counter token of mails, so in the end it will say I have 10-mails in the junk folder. I want to avoid this by just throwing the incoming mails from that sender to the deleted-items folder and also marking the mail as "read" so that I don't see

EscapeDataString having differing behaviour between Powershell IDE and Powershell console

蹲街弑〆低调 提交于 2019-12-06 23:30:56
问题 I'm a bit confused with this issue! I'm building a bigger script and it was working in the ISE but not in a powershell console. I've managed to track it down to the [System.Uri]::EscapeDataString function which seems to be behaving differently between the different environments, for example in my powershell console () ' & ! are not being escaped, where as in the IDE they are all being escaped. Am I missing something? My test code: [System.Uri]::EscapeDataString("/?:@%!$&'/*+,;=()") ISE output

Multiple Actions for one Outlook rule in Powershell

﹥>﹥吖頭↗ 提交于 2019-12-06 12:04:35
I have a question about Outlook Rules in Powershell. I wrote some code that successfully stores any incoming e-mail from a certain sender to the deleted-items folder. I did this because when the mails enter the junk folder, the junk folder still has the counter token of mails, so in the end it will say I have 10-mails in the junk folder. I want to avoid this by just throwing the incoming mails from that sender to the deleted-items folder and also marking the mail as "read" so that I don't see the clutter in the deleted items folder. The question is really: Can I add multiple actions to the

Send mail via gmail with PowerShell V4

无人久伴 提交于 2019-12-06 06:24:19
I have been using this PowerShell script to send my an email to me when opened. $EmailFrom = "notifications@somedomain.com" $EmailTo = "anything@gmail.com" $Subject = "sample subject" $Body = "sample body" $SMTPServer = "smtp.gmail.com" $SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587) $SMTPClient.EnableSsl = $true $SMTPClient.Credentials = New-Object System.Net.NetworkCredential("YOURUSERNAME", "YOURPASSWORD"); $SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body) I changed the $EmailTo to my email address, and the YOURUSERNAME / YOURPASSWORD to my correct login information. I

Tell PowerShell ISE to not send stderr to Write-Error

允我心安 提交于 2019-12-05 21:13:44
问题 The PowerShell console and the PowerShell ISE behave differently when executables write to the standard error stream ( stderr ). The console (powershell.exe) displays it like standard output. For example, when I get a status with Mercurial on a non-repository, it writes to standard error: > hg st -R C:\Windows abort: repository C:\Windows not found! However, in the PowerShell ISE ( powershell_ise.exe ), that error gets passed to PowerShell's Write-Error cmdlet: > hg st -R C:\Windows hg.exe :