powershell

PowerShell flattening nested JSON and convert it to CSV

╄→尐↘猪︶ㄣ 提交于 2021-01-29 14:38:13
问题 I have a JSON file below. I am trying to flatten and convert it to CSV. { "tempid": "template_86CE6E3BE3AD4EAB95727BCBFAD6A83C", "auid": "audit_00006F5D7A114CE59AD572E3E878E726", "created_at": "2017-01-12T08:54:48.835Z", "Dateat": "2019-04-26T14:24:09.496Z", "Datefrom": { "score": 64, "duration": 1754, "space": { "device_id": "88888888888888", "owner": "John Paul" }, "header_items": [ { "item_id": "357085FF-B66A-4C28-B9D", "children": "66f7893245d45-ea77-0020" }, { "parent_id": "357949D",

Remove Blank Space From Output in PowerShell

喜夏-厌秋 提交于 2021-01-29 14:34:12
问题 I'm developing code for monitoring memory that a specific program is using and then, if memory goes too high, it's gonna kill the process. I'm wondering how I could remove extra blank spaces backward and forward the result, and then put the content into a variable. Right now, the code is working, but it brings me some blank spaces. I know it's because of the Format-Table -Hide function, but I don't know how to fix it. Eg.: With Chrome process. $Pmemory = Get-Process -Name chrome | Group

make webcam device invisible to a process

六月ゝ 毕业季﹏ 提交于 2021-01-29 14:00:19
问题 Some context: I have an application that opens the first webcam device on Windows 10 64bit (whatever index 0 is during enumeration of devices) and does some processing on the frames. The application's source code is not accessible. Question: I need to make this application to work with two webcams at the same time. I thought maybe there is a way to do the following: hide webcam 2 run application (picks up webcam 1) hide webcam 1, unhide webcam 2 run application (picks up webcam 2) Is there a

How to run a Powershell command in Rundeck with pipes

橙三吉。 提交于 2021-01-29 13:23:07
问题 I'm using Rundeck version 3.0.13 to send powershell commands over WinRM to Windows Server 2016 hosts. Is there any way to run a powershell command with pipe characters as a single command? For example, I'd love to be able to execute a command like this to start non-disabled services: Get-Service | where-object {$_.StartType -ne "Disabled"} | foreach-object {Start-Service $_} But I get the error back "where-object" command not found. The WinRM node executor runs the command as an argument to

Calculate two audio duration with frame

北城余情 提交于 2021-01-29 13:20:33
问题 I am stuck, I need a small logic. I have two audio durations x = "00:00:07:18" y = "00:00:06:00" H : M: S: F Answer should be x + y = 00:00:13:18 H=hours S= seconds M=minutes F=frame My question is if x = "00:00:03:14" y = "00:00:13:18" answer should be x + y = **00:00:17:02** If the frame is greater than 30 it should increase 1 in second. I am using power shell. How can I determine the logic to calculate both of this? 回答1: Calculation of the first 3 parts ( hour:minute:second ), we can

Is it possible to extract / read part of a file within a zip using powershell?

梦想与她 提交于 2021-01-29 13:09:17
问题 I have a powershell 4.0 script that does various things to organise some large zip files across an internal network. This is all working fine, but I am looking to make a few improvements. One thing that I want to do is extract some details that are within an XML file within the ZIP files. I tested this on some small ZIP files by extracting just the XML which worked fine. I target the specific file because the zip can contain thousands of files that can be pretty large. This worked fine on my

PowerShell fill up form and submit

假如想象 提交于 2021-01-29 13:07:51
问题 I need to fill up a form of an internal site. I was able to successfully login to the portal page using this code $ie = New-Object -Com InternetExplorer.Application $ie.Visible = $true $ie.Navigate("https://some-internal-ip/login") while ($ie.ReadyState -ne 4) {Start-Sleep -m 100}; #Login $form = $ie.document.forms[0] $inputs = $form.GetElementsByTagName("input") ($inputs | where {$_.Name -eq "username"}).Value = $username ($inputs | where {$_.Name -eq "password"}).Value = $password ($inputs

check for last number of users logged in to machine?

点点圈 提交于 2021-01-29 12:43:33
问题 I'm trying to come up with a powershell script thatcan determine the last number of users that logged on to a machine. I'm stuck on to how to approach it. If I'm correct, using a get-wmiobject call will only get the last user. I'm wondering if maybe there is a call I can do to get the history of something like the user folder and get the last users that modified that?Or is there some simpler way? 回答1: http://social.technet.microsoft.com/Forums/en/winserverpowershell/thread/c61dc944-6c40-4ab8

Updated how can i edit my script to import additionnal fields to mailchimp

时光怂恿深爱的人放手 提交于 2021-01-29 12:41:24
问题 hi and sorry for my errors now i have problem with fields, actually instead of having : firstname, lastname, email fields, business asking me to have 2 additionnal fields, job and country and i've updated my script with this : $person = @{ email_address=$email status ="subscribed" merge_fields = @{ FNAME=$firstname LNAME=$lastname title=$title Country=$country $dayAgo = (Get-Date).AddDays(-5).Date $users = Get-ADUser -Filter {whenCreated -ge $dayAgo} -Properties whenCreated, StartDate,

Copy rename move files powershell

拜拜、爱过 提交于 2021-01-29 12:32:05
问题 After a short period of time I managed to create a script that copies from one server to another, after that it renames it with date and time and then it should move the files to another location. I keep getting an error, and I am not entirely sure what is happening $server2 = "C:\Users\nicolae.calimanu\Documents\A\" # UNC Path. $datetime = Get-Date -Format "MMddyyyy-HHmmss" $server3 = "C:\Users\nicolae.calimanu\Documents\C\" # UNC Path. foreach ($server1 in gci $server1 -recurse) { Copy-Item