powershell-4.0

Remote command failure even after unencrypted traffic is true

回眸只為那壹抹淺笑 提交于 2019-12-11 11:41:54
问题 I am trying to open remote PSSession from one PC to another. Both PCs are in the LAN and reachable, but whenever I try to enter PSSession the following error occurs: Enter-PSSession : Connecting to remote server pc2 failed with the following error message : The WinRM client cannot process the request. Unencrypted traffic is currently disabled in the client configuration. Change the client configuration and try the request again. For more information, see the about_Remote_Troubleshooting Help

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=@'

Powershell download file from website ie.document method

偶尔善良 提交于 2019-12-11 03:45:36
问题 I have created a little script that log's on to a https website using Internet explore 11. I had a manual mouse click to Download file to IE but im getting the prompt to save open file I would like to be able to bypass this due to im going to run this in the back ground? Am I missing a param on the end of my ie.navigate(url) to just save the file? As I stated above I'm using IE11 for this and downgrading is not an option. Any help would be great $username= get-content -Path c:\username.txt

Automatically Create Indexes in Different Filegroup, edit Publish Profile Script

ε祈祈猫儿з 提交于 2019-12-11 03:42:00
问题 I need a way to automatically move clustered indexes into one filegroup : ClusteredFilegroup, and all nonclustered indexes to a different filegroup NonClusteredFilegroup upon DDL creation . We have sql publish profile which creates similar script below every weekly deployment. How do I utilize powershell to conduct this? I would like to have powershell add words ON [ClusteredFilegroup] after every table creation or ON [NonClusteredFilegroup] for every nonclustered index. Powershell should be

What's the maximum number of columns for Format-Table cmdlet in PowerShell

笑着哭i 提交于 2019-12-11 02:37:51
问题 I'm writing a script emitting output in columns using Format-Table, and cannot get more than 9 to show (either with or without the -AutoSize argument). Just in case it is not my fault, just something undocumented: What's the maximum number of columns which Format-Table can show? If it is unbound, I'll distill a small reproducible case from my script. I'm using PowerShell 4.0, and create the objects to list like this: New-Object PSCustomObject -Property ([Ordered] @{ "BDS #" = $bdsVersion

Can Powershell Give Me Information on the Server's Certificate Used By Invoke-WebRequest?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-10 23:42:24
问题 For instance, in Powershell 4, $StackExAPIResponse = Invoke-WebRequest https://api.stackexchange.com/users/104624?site=serverfault -TimeoutSec 3 -ErrorAction Stop That command works perfectly well, but, is there any way for me to also get the information about the SSL certificate used in that request, such as hash algorithm, expiration date, etc.? Edit: I'd also accept something with Invoke-RestMethod , etc... 回答1: The PowerShell cmdlets don't have a native way to do this. You will probably

Calling PowerShell's where-object from C#

自古美人都是妖i 提交于 2019-12-10 23:05:46
问题 How can I call Where-Object (without filter) from C#? I can't parse output, because I want to pass it to pipeline(not in example below). PS: Get-MailboxPermission username | Where-Object {$_.AccessRights -match "FullAccess" -and $_.IsInherited -eq $False} C#: Collection<PSObject> results = null; Command command1 = new Command("Get-MailboxPermission"); command1.Parameters.Add("Identity", mailbox); command1.Parameters.Add("DomainController", _domainController); //I cannot use Filter. This is

How to edit a .property file in powershell

隐身守侯 提交于 2019-12-10 22:54:45
问题 I have a application.properties file in following format application.name=some thing application.version=4.1.0.1 application.list=abc.def, ghi.jkl Now my task is to append mno.pqr to application.list I am able to read it using $AppProps = convertfrom-stringdata (get-content .\application.properties -raw) I changed the Application.list value in $AppProps . How to save it back to original Application.properties file..? 回答1: You can try the following: $AppProps.GetEnumerator() | % { "$($_.Name)=

Is there a way to optimise my Powershell function for removing pattern matches from a large file?

耗尽温柔 提交于 2019-12-10 19:35:31
问题 I've got a large text file (~20K lines, ~80 characters per line). I've also got a largish array (~1500 items) of objects containing patterns I wish to remove from the large text file. Note, if the pattern from the array appears on a line in the input file, I wish to remove the entire line, not just the pattern. The input file is CSVish with lines similar to: A;AAA-BBB;XXX;XX000029;WORD;WORD-WORD-1;00001;STRING;2015-07-01;;010; The pattern in the array which I search each line in the input

PowerShell Workflow Thread Limit

霸气de小男生 提交于 2019-12-10 18:21:02
问题 I have a PowerShell workflow that looks something like this, except what each Foo function does is normally very different: function Foo1 { "Foo1 : {0:hh}:{0:mm}:{0:ss}" -f (Get-Date) Start-Sleep 2 } function Foo2 { "Foo2 : {0:hh}:{0:mm}:{0:ss}" -f (Get-Date) Start-Sleep 2 } function Foo3 { "Foo3 : {0:hh}:{0:mm}:{0:ss}" -f (Get-Date) Start-Sleep 2 } function Foo4 { "Foo4 : {0:hh}:{0:mm}:{0:ss}" -f (Get-Date) Start-Sleep 2 } function Foo5 { "Foo5 : {0:hh}:{0:mm}:{0:ss}" -f (Get-Date) Start