powershell-2.0

Powershell script to find applications that come with their own Java versions

佐手、 提交于 2021-02-05 08:26:27
问题 I am looking for a way to find out from all installed applications, one that comes with its own java version. There are scripts online to see the version installed on PCs but not the one to get the applications that uses Java and what versions of java they have. I found something close with using system explorer where I can view all running processes but what i want is a script that can find such applications with the java versions they use and then export the result as csv file or something.

Powershell Service Account Password Change Logon Failure

寵の児 提交于 2021-02-04 17:38:05
问题 i am trying to use a powershell script that allows me to change the user account and password a specific service runs under. $account="domain\account" $password="password" $svc=gwmi win32_service -filter "name='MyService'" $svc.change($null,$null,$null,$null,$null,$false,$account,$password,$null,$null,$null) I could check that the account was changed but when i tried to run the service from the Service.msc GUI it fails with a logon failure. If I use to start the service from the script itself

Unable to obtain status (Disable) of Local user

我与影子孤独终老i 提交于 2021-01-29 21:56:53
问题 I ‘m trying to obtain a list of Local Users with Group Membership and Disabled status. I had some success however could not get the corresponding Disable status of each local user. I’m using WMI in conjunction with ADSI to obtain a Disable Status of local users. The Disable Status property is not available with ADSI. Since, I’m a PS newbie any alternative options or explanation would be greatly appreciated. FYI: These are standalone servers not member servers $adsi = [ADSI]"WinNT://$env

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",

powershell ping continous for specific duration and save log

谁都会走 提交于 2021-01-29 08:09:06
问题 I am new to powershell when searching for test my internet connection i found this simple code ping google.com -t | Select-String "Reply" | foreach $_ { $a = Get-Date$a.ToString() + " " + $_ } | Out-File "C:\users\"your account"\Documents\pingLog$((get-date).tostring("HHmmss")).txt" try it and success but i want to set ping for specific duration say about 30 minutes or 1 hour so i try modified the code with this $stopTime = (Get-Date).AddMinutes(30) $results = do { $now = Get-Date ping google

Parsing Text file and placing contents into an Array Powershell

余生颓废 提交于 2021-01-28 14:11:24
问题 I am looking for a way to parse a text file and place the results into an array in powershell. I know select-string -path -pattern will get all strings that match a pattern. But what if I already have a structured textfile, perhaps pipe delimminated, with new entries on each line. Like so: prodServ1a prodServ1b prodServ1c C:\dir\serverFile.txt How can I place each of those servers into an array in powershell that I can loop through? 回答1: You say 'pipe delimited, like so' but your example isn

Exception not caught when using PowerShell command line but caught as expected when using PowerShell ISE

大憨熊 提交于 2021-01-28 05:00:02
问题 I am running PowerShell 2.0. I have a PowerShell script that adds a record to the database and returns the ID of the record added. The record ID is returned as a property called new_deal_id within a DataRow object (called ResultSet ). If there is a problem on the database end it is possible that the new_deal_id property does not get set, or doesn't exist at all. To counter this scenario I wrapped the reading of the property in a try/catch block as shown here. try { $ErrorActionPreference =

How to pause a foreach PowerShell loop

那年仲夏 提交于 2021-01-28 04:50:44
问题 I have created this simple script below to loop through a file containing a list of users and apply quota rules for each user in the file. It works, but during processing it fails sometimes as I believe the large number of users in the text file blocks access at times. Is there a way to get the loop to pause for 5 - 10 seconds after each iteration of the foreach loop or after five iterations of the foreach loop until the filer has updated those quotas completely and then move on to the next

Fliter results of gci with strings from a textfile in Powershell

那年仲夏 提交于 2021-01-27 17:42:45
问题 After having ripped all my mother's DVD library to a Drobo-FS I setup for her, she was faced with the problem that having so many choices just a mouse-click away from made it too hard to choose. My solution was a Powershell script that starts playing a random movie: $files = Get-Childitem -Recurse -Path "\\DROBO-FS\Videos\Movies" -include *.mkv,*.avi,*.mp4,*.m4v $ran = Get-Random -minimum 0 -maximum ($files.length - 1) $movie = $files[$ran] & "C:\Program Files (x86)\MPC-HC\mpc-hc.exe" $movie

How to find PC from list of users

。_饼干妹妹 提交于 2021-01-27 17:22:41
问题 I need some help. I'm not so sure that this possible. I have list of samAccountName in .csv file, and from this I need to get their PC name and IP. I'm not so sure how to build script like this. 回答1: One way of doing this could be to loop through all computers in your environment and test each one. This of course will be SLOW There is no example of what your CSV file looks like in the question, but if it looks something like this: "SamAccountName","title" "jdoe","testuser" "rboizov","system