powershell

Azure Pipelines agent proxy settings not working as expected

痴心易碎 提交于 2021-02-10 05:19:11
问题 When configuring a local build agent on a Windows 2016 server, I use the following proxy config settings: .\config.cmd --proxyurl http://192.3.4.5:8080 --sslskipcertvalidation This allows the build server to connect to Azure DevOps behind the proxy without issues, however the powershell build is having trouble connecting out to the internet. I solved this by setting an environmental variable at the beginning of the build command as such: $env:http_proxy = "192.3.4.5:8080" The final issue is a

Remove Ellipse from Table Output

左心房为你撑大大i 提交于 2021-02-10 05:15:07
问题 I am trying to output to a text file the results of the powershell cmdlet Compare-Object The problem is I cannot eliminate the ellipse truncation. The code below provides a table formatting definition variable which specifies a width of 1000 for the Path column. Yet the output file always truncates the Path column at 122 characters. The Compare-Object cmdlet is comparing two ArrayLists which are just lists of file path strings from common folder paths between two servers. What I am attempting

Detecting a PowerShell Switch

喜你入骨 提交于 2021-02-10 04:22:09
问题 I'm developing a PowerShell cmdlet in C#, and have true/false switch statements. I have noted that I need to specify -SwitchName $true, if I want the bool to be true, otherwise I get: Missing an argument for parameter 'SwitchName'. Specify a parameter of type 'System.Boolean' and try again. The switch is decorated as such: [Parameter(Mandatory = false, Position = 1, , ValueFromPipelineByPropertyName = true)] How can I just detect the presence of the switch (-SwitchName sets to true, absence

Can I specify a dll from which to use New-Object in Powershell?

有些话、适合烂在心里 提交于 2021-02-10 04:19:47
问题 I have a scenario where by I need to New-Object a type but there are multiple types with the same name and namespace. I can't find how New-Object decides which dll to create the type from when it exists in multiple places. Is it possible to specify? Ideally I'd like to pass the dll name to the New-Object but there doesn't appear to be an option for this. 回答1: Specify the full assembly-qualified type name: New-Object -TypeName 'MyType, AssemblyName, Version=1.0.0.0, Culture=neutral,

Can I specify a dll from which to use New-Object in Powershell?

大憨熊 提交于 2021-02-10 04:19:30
问题 I have a scenario where by I need to New-Object a type but there are multiple types with the same name and namespace. I can't find how New-Object decides which dll to create the type from when it exists in multiple places. Is it possible to specify? Ideally I'd like to pass the dll name to the New-Object but there doesn't appear to be an option for this. 回答1: Specify the full assembly-qualified type name: New-Object -TypeName 'MyType, AssemblyName, Version=1.0.0.0, Culture=neutral,

Read most recent e-mail from outlook using PowerShell

北城以北 提交于 2021-02-10 04:13:24
问题 I am trying to read my Outlook e-mail with the subject line "Automation" and process further with custom script. The below script reads the e-mail with the subject line but it reads the entire count of e-mail with the subject "Automation". I want to be able to read only the most recent e-mail and process only that specific e-mail content and mark the e-mail as unread. And then read the next new e-mail with the same subject and process only the specific content. Add-type -assembly "Microsoft

Read most recent e-mail from outlook using PowerShell

风格不统一 提交于 2021-02-10 04:09:10
问题 I am trying to read my Outlook e-mail with the subject line "Automation" and process further with custom script. The below script reads the e-mail with the subject line but it reads the entire count of e-mail with the subject "Automation". I want to be able to read only the most recent e-mail and process only that specific e-mail content and mark the e-mail as unread. And then read the next new e-mail with the same subject and process only the specific content. Add-type -assembly "Microsoft

'rm' is not recognized as an internal or external command when trying publish a capacitor plugin

跟風遠走 提交于 2021-02-10 03:59:26
问题 I am trying to publish a capacitor plugin. According to the error it is not able to recognize rm . I am using Window's Powershell (VC Code) The following error is being generated in the powershell when npm publish in run PS C:\Users\xxxxx\Documents\demo-plugin> npm run build demo-plugin@0.0.1 build C:\Users\xxxxx\Documents\demo-plugin npm run clean && tsc demo-plugin@0.0.1 clean C:\Users\xxxxxx\Documents\demo-plugin rm -rf ./dist 'rm' is not recognized as an internal or external command,

Powershell: XPath cannot select when element has “xmlns” tag?

对着背影说爱祢 提交于 2021-02-09 11:55:55
问题 I've got a very simple xml, as below: <?xml version="1.0" encoding="utf-8"?> <First> <Second> <Folder>today</Folder> <FileCount>10</FileCount> </Second> <Second> <Folder>tomorrow</Folder> <FileCount>90</FileCount> </Second> <Second> <Folder>yesterday</Folder> <FileCount>22</FileCount> </Second> </First> Then I have a powershell script to select "Folder" element: [xml]$xml=Get-Content "D:\m.xml" $xml.SelectNodes("//Folder") It outputs: #text ----- today tomorrow yesterday No problem. But if I

Is it possible to set a users memberOf property in Active Directory using Powershell

北战南征 提交于 2021-02-09 08:20:05
问题 I need to create a Powershell script that sets some user attributes in Active Directory. I'm using the Set-AdUser command and passing in a user object as follows: $user = Get-AdUser -Identity $userIdentity $user.MemberOf = $dn_of_group Set-ADUser -Instance $user this returns an error of 'The adapter cannot set the value of property "MemberOf"'. Is it possible to set the MemberOf property from powershell? If so, what am I doing wrong? 回答1: You cannot modify the MemberOf property - you need to