powershell-3.0

Get Azure VM Detail by PowerShell

血红的双手。 提交于 2019-12-08 15:48:20
问题 I am trying to run Get-AzureVM PowerShell command, it is running fine but not return any output. Also tried in following flavor but still blank result any idea? Get-AzureVM -Name "vmname" |Select-Object name,instancesize,location 回答1: You should call Select-AzureSubscription "subscription name" first. It likely is defaulting to a subscription that doesn't have any virtual machines in it. To view your current subscription names call: Get-AzureSubscription | select SubscriptionName 回答2:

System.DirectoryServices.DirectorySearcher objectGUID value incorrect System.Byte[]

前提是你 提交于 2019-12-08 09:58:08
问题 I have code that I have modified that I got from here: https://blog.schmijos.ch/2013/09/27/ad-export-with-get-qaduser-is-too-slow/ The code I have modified includes pagesize, so it can grab more than 1000 accounts. It changes the date values from some really big number to a readable date/time stamp. The entire modified code I have here... function CreateQueriedCsvDataSheet { $csvFileWithPath = 'C:\Scripts\Tests\testResults.csv' $DomainControlConnector = 'www.example.com' $DomainName =

Powershell datagridview cell click event

我是研究僧i 提交于 2019-12-08 09:45:29
问题 I have a powershell script in that script i am using datagridview. My script is working fine. All looks ok to me. My issue is i want to get the first column value of selected row. To fulfill this i need to add event (cell click/cell content click/cell mouse click). I am not able to figure it out. How to add event. Can somebody please advise me on this? $datagridview1_CellMouseClick = [System.Windows.Forms.DataGridViewCellEventHandler]{ write-host $_.RowIndex # This displays the row number

ConvertTo-SecureString gives different experience on different servers

淺唱寂寞╮ 提交于 2019-12-08 07:46:51
问题 I am running into an issue creating a Credential Object from an XML File on a remote server. Here is the code I am using to test XML File <Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"> <Obj RefId="0"> <TN RefId="0"> <T>Selected.System.Management.Automation.PSCredential</T> <T>System.Management.Automation.PSCustomObject</T> <T>System.Object</T> </TN> <MS> <S N="UserName">domain\username</S> <S N="Password"

How to use a powerhsell serialized object?

↘锁芯ラ 提交于 2019-12-08 07:41:00
问题 I have machine that I need to analyze for information. I use powershell to gather the information into an object and then I write that object out to a file using Export-Clixml myObject.xml . I then try to test import this object using $placeholder = Import-Clixml myObject.xml and this works fine as I can see all the methods and access data in the methods. However, whenever I try to use this object in my program where this type of object is required, I get a Type Mismatch error. Is this not

I need to delete users from Active Directory using a imported csv file

末鹿安然 提交于 2019-12-08 07:32:41
问题 I have a CSV file with a list of user names, I need to delete all of these users from Active Directory using the Remove-ADObject command . I am not very familiar with the syntax for this command - hoping you guys can help me here. Import-Module activedirectory $list = Import-CSV C:\Users\user\Desktop\deleteuserstest.csv forEach ($item in $list) { $samAccountName = $item.samAccountName Remove-ADobject -Identity $samAccountName } 回答1: You have to use DN or GUID with Remove-ADObject. You can do

invoke-webrequest to get complete web page with images

你说的曾经没有我的故事 提交于 2019-12-08 06:45:00
问题 How do I get the output file to contain the images on the webpage and not just the links to the images? PS C:\temp> Invoke-WebRequest http://mitpress.mit.edu/sites/default/files/titles/content/sicm/book-Z-H-51.html -OutFile C:\temp\51.html 回答1: You need to explore the page a bit to figure out some of details. Here's a complete script which I've tested successfully. Invoke-WebRequest http://mitpress.mit.edu/sites/default/files/titles/content/sicm/book-Z-H-51.html | select -expand images |

Reference .Net .dll from powershell script

荒凉一梦 提交于 2019-12-08 05:23:09
问题 Could you please help me in referencing .Net .dll from powershell script? I'm using powershell ISE to write/debug script. I've some .net code which is referencing Nuget package in it and I want to embedded that code in powershell script. It works well if I do copy required .dlls in C:\WINDOWS\system32\WindowsPowerShell\v1.0 and script's root(C:\TestProjects\UpdateLocalNugetRepository) path. I don't want to do that beacuse in production we can not copy .dlls to system32 folder.I know that I'm

Speed up PowerShell script for Windows Registry search (currently 30 minutes)

天涯浪子 提交于 2019-12-07 19:01:21
问题 I'm working on a script for use in Windows 7 and Windows 10 for a Windows Registry search in HKLM:\Software\Classes. So far my code works, but it's extremely slow. It takes about 30 minutes to complete. I need to use Set-Location also to avoid an error with Get-ItemProperty, which occurs because the $path is not a valid object. How can I speed this code up? What's wrong? File regsearch.ps1 (Mathias R. Jessen's answer applied) Function Get-RegItems { Param( [Parameter(Mandatory=$true)] [string

How to set Low I/O (“background”) priority in Powershell

心不动则不痛 提交于 2019-12-07 18:08:39
问题 There's this powershell script which can set processes' priorities from "Idle" to "Realtime" but some tools offer another priority level which drops a process's priority even below: How to set that in Powershell? 回答1: It is not clear to me whether the IO priority can be set. The SetProcessInformation() call takes a PROCESS_INFORMATION_CLASS as an argument and that only defines ProcessMemoryPriority. I was having problems with a powershell script getting run out of task manager with a memory