powershell

how to print XML documents to the REPL console when using ConvertTo-Xml in Powershell?

此生再无相见时 提交于 2021-02-11 14:25:27
问题 "almost" printing the elements to the console: PS /home/nicholas/flwor> PS /home/nicholas/flwor> $nodes = Select-Xml "/" $xml PS /home/nicholas/flwor> PS /home/nicholas/flwor> $nodes Node Path Pattern ---- ---- ------- #document InputStream / PS /home/nicholas/flwor> not quite sure how print the actual node values. for larger context,reading in a file and converting it to xml as: PS /home/nicholas/flwor> PS /home/nicholas/flwor> $xml=./bookstore.xml PS /home/nicholas/flwor> PS /home/nicholas

Where is the MailChimp Connector for PowerShell?

╄→尐↘猪︶ㄣ 提交于 2021-02-11 14:23:39
问题 How and where "is" the connector: MailChimp MailChimp is a SaaS service that allows businesses to manage and automate email marketing activities, including sending marketing emails, automated messages and targeted campaigns. This connector is available in the following products and regions: https://docs.microsoft.com/en-us/connectors/mailchimp/ reading in env variables as: nicholas@mordor:~/chimp$ nicholas@mordor:~/chimp$ pwsh chimp.ps1 Name Value ---- ----- chimp_key c.................7 foo

Differences in length of access token generated from PowerShell and C# .Net library of PowerShell respectively

冷暖自知 提交于 2021-02-11 14:13:28
问题 I am new in Azure DevOps, I am acquiring access token of Azure DevOps by two ways Windows PowerShell PowerShell within WPF application In above two ways, I am able to get access token but there is a big difference in size of access token. If I follow the 1st method I am getting full access token and it works fine. But if I use the 2nd method, it returns access token with small size, resulting I get a 401 error when I use this access token. I am sharing outputs from both ways 1. Using

Filter output (where-object) from variable

Deadly 提交于 2021-02-11 14:12:39
问题 I am running a test on servers with the following line: Get-WmiObject Win32_Service -ComputerName "myserver" -Filter "State='Running'" | where-object ??? }| Foreach-Object { New-Object -TypeName PSObject -Property @{ DisplayName=$_.DisplayName State=$_.State } | Select-Object DisplayName,State # Export all info to CSV } | ft -AutoSize I would like to create a variable like this: $IgnoreServices = '"Wireless Configuration","Telephony","Secondary Logon" and send this to Where-Object. Can I do

I want to fetch the SCOM alerts data. But I keep getting the error 401. I am passing the credentials right

蹲街弑〆低调 提交于 2021-02-11 14:12:35
问题 My script looks like import requests import base64 user="domain\\username" pass="password" Authentication_mode="Windows" tok=Authentication_mode+":"+user+":"+pass #referring the doc for authentication at https://docs.microsoft.com/en-us/rest/api/operationsmanager/authentication/login token=base64.b64encode(bytes(token,'utf-8')).decode() headers={'content-type':'application/json', 'Authorization': 'Basic %s' % token } payload={} url="http://<Servername>/OperationsManager/authenticate" respone

Powershell Windows Form Border Color / Controls?

安稳与你 提交于 2021-02-11 14:11:26
问题 Is there a way to set the border color Red on focus and then back to none when focus is lost? I'd also like to set the border style thicker at the same time if possible. $form= New-Object system.Windows.Forms.Form $form.Text= "Testing" $form.StartPosition= 'CenterScreen' $form.ClientSize= '400,200' $form.text= "Form" $form.BackColor= "#0077f7" $form.TopMost= $true $form.AutoScroll= $true $form.Add_KeyDown({if ($_.KeyCode -eq "Escape") { $form.Close() } }) # if escape, exit $form.KeyPreview=

Differences in length of access token generated from PowerShell and C# .Net library of PowerShell respectively

左心房为你撑大大i 提交于 2021-02-11 14:10:25
问题 I am new in Azure DevOps, I am acquiring access token of Azure DevOps by two ways Windows PowerShell PowerShell within WPF application In above two ways, I am able to get access token but there is a big difference in size of access token. If I follow the 1st method I am getting full access token and it works fine. But if I use the 2nd method, it returns access token with small size, resulting I get a 401 error when I use this access token. I am sharing outputs from both ways 1. Using

Powershell and winapi SystemParametersInfo function

狂风中的少年 提交于 2021-02-11 14:02:28
问题 I was trying this: $f=@' [DllImport("user32.dll")]public static extern int SystemParametersInfo( int uAction, int uParam, int lpvParam, int fuWinIni ); '@ $mSpeed = Add-Type -memberDefinition $f -name "mSpeed" -namespace Win32Functions -passThru $get = 0x0070 $set = 0x0071 $srcSpeed = $mSpeed::SystemParametersInfo($get, 0, 0, 0) $newSpeed = $srcSpeed + 1 $mSpeed::SystemParametersInfo($set, 0, $newSpeed, 0) but the mouse speed does not return. How do I write this down correctly? 回答1: According

Method Invocation .Foreach failed, System.Object doesn't contain a method named 'foreach'

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-11 14:01:34
问题 I am trying to execute a script in PowerShell 2.0 that will check the trust relationship between the computer and domain controller for all computers in Active Directory. I got the code from this website: https://adamtheautomator.com/trust-relationship-between-this-workstation-and-the-primary-domain-failed/ Here is the code: $localCredential = Get-Credential @(Get-AdComputer -Filter *).foreach({ $output = @{ ComputerName = $_.Name } if (-not (Test-Connection -ComputerName $_.Name -Quiet

Powershell script scheduled task output to log file

血红的双手。 提交于 2021-02-11 13:56:33
问题 I have Powershell script with some Write-Host but I want to use it as scheduled task. I added it as scheduled task with this: $action = New-ScheduledTaskAction -Execute "$pshome\powershell.exe -WindowStyle Hidden" -Argument "-File $FilePath" $trigger = New-ScheduledTaskTrigger -Once -At (Get-Date).Date -RepetitionInterval $repeat Register-ScheduledTask -TaskName $Name -Trigger $trigger -RunLevel Highest -Action $action Can I make it write to log file? Is it possible to make it write to file