powershell-3.0

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

Understanding the get-culture command

你。 提交于 2021-01-28 12:04:40
问题 I recently had some trouble with culture dependent returned values from my powershell script. The same script returned different values, depending on which machine it was. So I thought that maybe the culture settings are different and for one server it returned. get-culture : de-DE for the other it was like : en-US One value is for the keyboard settings but what does the other (second) stand for? And is the second value bound to the OS installation or is that just a setting? Is there a

List hard Disk Information on remote computers within a domain

旧街凉风 提交于 2021-01-28 04:17:13
问题 I am trying to get a list of hard disk information. At the moment I would only want the list to show the model of the hard disk that each computer contains. I have the below Get-WMIObject win32_diskdrive -computer (Get-Content C:\Temp\DiskDrives\Computers.txt) | Select model | Export- CSV "C:\Temp\DiskDrives\Machines.csv" The computers.txt file contains a list of computers that the code goes through one by one. The above works to a point it will list the drives that it can find for a machine

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

How to find PC from list of users

久未见 提交于 2021-01-27 17:21:59
问题 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

Create CSV file in each subdirectory of target directory

孤街醉人 提交于 2021-01-27 15:08:36
问题 I have folder with files as below: D:\TESzz\Background\BG_Flash-Zootopia-HD-Desktop-Wallpapers.jpg D:\TESzz\Background\BG_NimmHBD.jpg D:\TESzz\Background\BG_Note5.jpg D:\TESzz\Icons\150x150.jpg D:\TESzz\Icons\Bathroom-gender-sign.png D:\TESzz\Icons\brocoli.png D:\TESzz\Icons\Carrot_Clipart_PNG_Image.png D:\TESzz\Icons\File.txt D:\TESzz\Icons\garlic.png D:\TESzz\Icons\ICONS.txt D:\TESzz\Icons\NoppNimm-1.jpg D:\TESzz\Icons\NoppNimmIcon.jpg D:\TESzz\Icons\NoppNimmIcon.png D:\TESzz\Icons

PowerShell function parameters syntax

荒凉一梦 提交于 2020-12-26 06:55:36
问题 Why do the Write-Host outside of the function work different than inside of the function? It seems like somehow the parameters variables are changing from what I declared it to be... function a([string]$svr, [string]$usr) { $x = "$svr\$usr" Write-Host $x } $svr = 'abc' $usr = 'def' $x = "$svr\$usr" Write-Host $x a($svr, $usr) Results… abc\def abc def\ 回答1: Don't call functions or cmdlets in PowerShell with parentheses and commas (only do this in method calls)! When you call a($svr, $usr) you

Run powershell script from Ansible

偶尔善良 提交于 2020-12-13 07:35:40
问题 I have a powershell script which takes multiple user inputs for file ex.- "C:\temp\foo.ps1", then it runs. I am trying to integrate that script with Ansible using win_shell module. How can I pass the user inputs for the powershell script :- - name: windows test command win_shell: C:\temp\Snapshots.ps1 args: stdin: C:\temp\test3.csv Script(powershell):- $CONumber = Read-Host "Enter the CO Number" SO this takes input from user, how can I edit this using vars_prompt variable? 回答1: To pass the

Run powershell script from Ansible

故事扮演 提交于 2020-12-13 07:35:26
问题 I have a powershell script which takes multiple user inputs for file ex.- "C:\temp\foo.ps1", then it runs. I am trying to integrate that script with Ansible using win_shell module. How can I pass the user inputs for the powershell script :- - name: windows test command win_shell: C:\temp\Snapshots.ps1 args: stdin: C:\temp\test3.csv Script(powershell):- $CONumber = Read-Host "Enter the CO Number" SO this takes input from user, how can I edit this using vars_prompt variable? 回答1: To pass the