powershell

Is there a single python module for colored text output in idle, Powershell and terminal?

笑着哭i 提交于 2021-01-29 18:29:45
问题 I need a python module that prints a colored output text for input() and print() functions which works on idle, Powershell, and Linux consols. I am just expecting few colors (no extra background features required) and the same functions should work equally on python idle, PowerShell, terminal, and cmd with full flexibility of code. 来源: https://stackoverflow.com/questions/62933340/is-there-a-single-python-module-for-colored-text-output-in-idle-powershell-and

How to run PowerShell script file without SDK?

耗尽温柔 提交于 2021-01-29 18:01:59
问题 I have a PowerShell script (ps file) which I'd like to run from a C# WPF app on the clients' machine. Most of the examples I found uses the PowerShell SDK, but I can not install that on the client computers. If I try to run my script simply with Process.Start like this: Process.Start("Powershell.exe", "myscript.ps"); I get the following error in the command window: File myscript.ps cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution

Powershell: Delete images of certain dimensions

百般思念 提交于 2021-01-29 17:53:21
问题 I want to delete all *.jpg files in a specific folder and all its subfolders which have e.g. width unequal 800 and height unequal 600 (leaving only 800x600 jpg images). Can someone tell me how to do this in Powershell? I know I can remove *.jpg images with Get-ChildItem -Path .\ -Filter *.jpg -Recurse | foreach ($_) {remove-item $_.fullname} But I can't seem to find how to select height/width of an image. 回答1: You could use the System.Drawing.Image .NET Object: $(Get-ChildItem -Filter *.jpg)

Add-Content to CSV Powershell

前提是你 提交于 2021-01-29 15:51:52
问题 When I run the below code I get a list of details in separate columns. $file = 'c:\output\testing.csv' Get-AdUser -filter "DisplayName -eq 'joe bloggs'" | Get-ADUser -Properties * | Select-Object givenName, surname, mail, @{ Label = "Country" Expression = { if ($_.Country) { $_.Country } else { "GB" } } ,samaccountname, department, description | Export-csv -path $file Output (1) is as follows: +-----------+---------+-----------------+---------+----------------+------------+-------------+ |

Extract Specific Filetypes From Multiple Zips to one Folder in Powershell

夙愿已清 提交于 2021-01-29 15:47:36
问题 I have Several zip files that Contain multiple filetypes. The ONLY ones I am interested in are the .txt files. I need to extract the .txt files only and place them in a folder of their own, ignoring all other file types in the zips files. All the zip files are in the same folder. Example -foo.zip --1.aaa --2.bbb --3.ccc --4.txt -foo2.zip --5.aaa --6.bbb --7.ccc --8.txt I want to have 4.txt and 8.txt extracted to another folder. I can't for the life of my figure it out and spent ages looking,

Powershell ScreenShot of a particular part

戏子无情 提交于 2021-01-29 15:41:47
问题 I want to take a screenshot of a very particular part of the screen. As if I just want to take a screenshot of an image in the centre of the screen. How can I do that? How can I setthe alignment to only crop a particular area. I got the code from stackoverflow only to take a screenshot: [Reflection.Assembly]::LoadWithPartialName("System.Drawing") function screenshot([Drawing.Rectangle]$bounds, $path) { $bmp = New-Object Drawing.Bitmap $bounds.width, $bounds.height $graphics = [Drawing

How to use Select-object to get details of process and thread in single query?

隐身守侯 提交于 2021-01-29 15:37:40
问题 when i executed the following query i am not getting the Name of the process only getting the thread details. Get-Process -ProcessName Test | Select-Object @{Label='CMPNAME';Expression={$_.Name}} -ExpandProperty Threads | Select-Object {$_.Id} OUTPUT : $_.Id ----- 8412 10460 10484 10508 10520 10524 回答1: You need to tell Select-Object which properties to select: Get-Process -ProcessName Test | Select-Object @{Label='CMPNAME';Expression={$_.Name}} -ExpandProperty Threads | Select-Object CMPNAME

Sync data between azure database and local database using cloud power shell

早过忘川 提交于 2021-01-29 15:20:39
问题 We are trying to sync an azure database and local SQL database using power shell. We are referencing the following URL for the sync process. https://docs.microsoft.com/en-us/azure/azure-sql/database/scripts/sql-data-sync-sync-data-between-azure-onprem Up to the database schema section, we can execute the script successfully. But when we execute the following code it is showing an error. $newSchema = [AzureSqlSyncGroupSchemaModel]::new() Error is “InvalidOperation: Unable to find type

Robocopy with PowerShell : ERROR 3 (0x00000003) The system cannot find the path specified

别等时光非礼了梦想. 提交于 2021-01-29 14:48:21
问题 I have a PowerShell script for backup that I used on Windows 2003 Server for a long time, and now I have a problem with it on Windows Server 2012 R2. I have this message when I try to execute it: 2019/09/18 08:40:25 ERROR 3 (0x00000003) Creating Destination Directory Z:\BACKUP\D\ The system cannot find the path specified. I run the PowerShell script in PowerShell ISE as administrator or as a scheduled task with highest privileges. The script is executing on a server on a domain (DOMAIN1) that

How to I make a cURL command call from .Net Core 3.1 Code

爱⌒轻易说出口 提交于 2021-01-29 14:44:07
问题 I have this complicated cURL command that is working perfectly : curl -L --negotiate -u : -b ~/cookiejar.txt "https://idp.domain.net/oauth2/authorize? scope=openid&response_type=code&redirect_uri=https://localhost:5001&client_id=client_id_here" However it is not really feasible to replicate in C# using HttpClient. But I need to call the cURL command from .Net Core code and get the response back. Is there a way to make a normal cURL command call in .Net Core (v3.1)? (In case you are interested