powershell-2.0

PowerShell, Web Requests, and Proxies

北慕城南 提交于 2019-11-28 16:12:59
When making a simple web request is there a way to tell the PowerShell environment to just use your Internet Explorer's proxy settings? My proxy settings are controlled by a network policy(or script) and I don't want to have to modify ps scripts later on if I don't have to. UPDATE: Great info from the participants. The final script template that I'll use for this will look something like the following: $proxyAddr = (get-itemproperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings').ProxyServer $proxy = new-object System.Net.WebProxy $proxy.Address = $proxyAddr $proxy

What can I do with C# and Powershell?

自古美人都是妖i 提交于 2019-11-28 15:53:29
I have a decent understanding of C# and a very basic understanding of powershell. I'm using Windows PowerShell CTP 3, which has been really fun. But I want to go beyond writing scripts/functions. Is there any cool stuff to do with C#? JaredPar I think the most interesting thing you can do with C# and PowerShell is to build CmdLet's. These are essentially plugins to PowerShell that are written in managed code and act like normal functions. They have a verb-noun pair and many of the functions you already use are actually cmdlets under the hood. http://msdn.microsoft.com/en-us/magazine/cc163293

Access web using Powershell and Proxy

百般思念 提交于 2019-11-28 15:32:44
问题 I can't seem to get access to a webpage using Powershell. I keep getting a "(407) Proxy Authentication Required". I've tried many things. I don't know what the proxy is or what kind of authentication it requires. The only thing I have access to is in IE it uses a script for configuring. I tried using some IPs from that, but no luck. Any ideas? Here is one example of what I tried: $wc = New-Object System.Net.WebClient $wc.Headers.Add("User-Agent","Mozilla/4.0+") $wc.Proxy = [System.Net

How to get all groups that a user is a member of?

佐手、 提交于 2019-11-28 15:21:59
PowerShell's Get-ADGroupMember cmdlet returns members of a specific group. Is there a cmdlet or property to get all the groups that a particular user is a member of? I fixed my mistake: Get-Member should be Get-ADGroupMember . Get-ADPrincipalGroupMembership will do this. Get-ADPrincipalGroupMembership username | select name name ---- Domain Users Domain Computers Workstation Admins Company Users Company Developers AutomatedProcessingTeam Single line, no modules necessary, uses current logged user: (New-Object System.DirectoryServices.DirectorySearcher("(&(objectCategory=User)(samAccountName=$(

Combine two or more rows in a csv using powershell

穿精又带淫゛_ 提交于 2019-11-28 12:57:22
问题 I receive a file from one of our clients that looks like this: (I added headers to this to it for easier processing). Sample Input: PlanID,Date,Transaction,Type,Ticker,Amount,Cash 01,121211,div,mf,fjk,25,cash 01,121211,div,mf,fjk,30,cash 01.121211,buy,mf,fjk,55,cash 02,121211,div,sd,ejd,10,cash 02,121211,div,sd,ejd,15,cash 02,121211,buy,sd,ejd,25,cash I need a way to combine all the rows with Transaction= 'div' by summing up their amount for each PlanID. This is how I desire my output to look

start-Transcript not capturing all output to log file..?

♀尐吖头ヾ 提交于 2019-11-28 11:55:29
I have the below code that goes through and gets scheduled tasks info and puts the output that occurs on the screen to a log file. However, what I have noticed is that all errors are logged EXCEPT for servers that have "Access is denied" - how can I log those errors in the log file as well. Below is the code: Start-Transcript -path $scheduledpath\logging.txt -append foreach ($name in $names) { Write-Host "Running Against Server $name" -ForegroundColor Magenta if ( Test-Connection -ComputerName $name -Count 1 -ErrorAction SilentlyContinue ) { #$Command = "schtasks.exe /query /S $name /fo CSV /v

Increase version of application.config automatically using powershell after every deployment

空扰寡人 提交于 2019-11-28 10:01:47
问题 I am new to powershell and I wanted to change version in an xml file after every deployment and. I referred to Unable to update a value in msbuild proj file using powershell. Below is the xml content: <?xml version="1.0" encoding="utf-8" ?> <configuration> <site> <add key="ShowAppConf" value="true"/> <add key="site.IsCsrfCheck" value="false" /> <add key="EnableDeviceFileAuthentication" value="false" /> <add key="EnableFileAuthentication" value="false" /> <add key="AppVersion" value="v0.1.7.21

Powershell: Autosize and Specific Column Width

好久不见. 提交于 2019-11-28 09:51:33
问题 Based on this SO question Powershell: Output collection of objects, I am able to wrap a collection of strings in multiple lines in one column. However, when I try to output the collection to table-view, the autosize would not allow me to specify specific column width. For example: id name items others --- ---- ----- ----- 01 a ("The first item", "The second item", "The third item", "...") ... 02 .... Here is my output: $colObjs | Select-object id, name, items, others` @{Expression={($_.items

powershell is missing the terminator: \"

浪尽此生 提交于 2019-11-28 09:35:22
I have the following script code #[string]$password = $( Read-Host "Input password, please" ) param ( [string]$ReleaseFile = $(throw "-ReleaseFile is required"), [string]$Destination = $(throw "-Destination is required") ) function unzipRelease($src, $dst) { $shell = new-object -com shell.application $zip = $shell.NameSpace($src) foreach($item in $zip.items()) { $shell.Namespace($dst).copyhere($item) } } # .\deployrelease.ps1 -ReleaseFile ".\deploy.zip" -Destination "." unzipRelease –Src '$ReleaseFile' -Dst '$Destination' I run the script with: .\deployrelease.ps1 -ReleaseFile ".\deploy.zip"

How to Run PowerShell v3 console in v2 mode

断了今生、忘了曾经 提交于 2019-11-28 09:07:44
问题 In recent updates of Windows Server 2008 R2, they are pushing Windows PowerShell V3.0 also along with that. But, our scripts are built and tested in V2 till now. How can I run PowerShell V3 Console in V2 mode.? Note: I tried "-Version 2" while starting the PowerShell.exe. But it is not working. 回答1: In what way is powershell.exe -version 2 not working? This is how you run v2 when v3 is installed. BTW, make sure that the PowerShell 2.0 engine is installed. Check Windows Features: 来源: https:/