powershell-2.0

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

半城伤御伤魂 提交于 2019-11-29 16:29:43
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.31.144402" /> </site> </configuration> and I am trying to increase value of revision version of

Powershell: Autosize and Specific Column Width

假如想象 提交于 2019-11-29 16:02:14
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 -join "`n")};Label="Items"} | ` Format-table -autosize -wrap Then the items column would be the whole

How to Run PowerShell v3 console in v2 mode

a 夏天 提交于 2019-11-29 15:48:57
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. 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://stackoverflow.com/questions/13864429/how-to-run-powershell-v3-console-in-v2-mode

Editing Web Config file using Microsoft PowerShell

断了今生、忘了曾经 提交于 2019-11-29 14:48:32
问题 i want to modify my web config file using powershell . i stuck in somewhere . i want to update appsettings and also connectionsstring information at the same time when i change them in powershel I have this code but it changes only apppsettings value when i change it here and run it but i also want to include connectionstring here. How can i achieve it ? $webConfig = "C:\Inetpub\Wwwroot\application\web.config" $doc = new-object System.Xml.XmlDocument $doc.Load($webConfig) $doc.get

Having a optional parameter that requires another parameter to be present

孤人 提交于 2019-11-29 13:59:43
问题 Quite simply, how do I initialize the params part of my Powershell Script so I can have a command line arguments like Get-Foo [-foo1] <foo1Arg> [-foo2 <foo2Arg> [-bar <barArg>]] So the only time I can use -bar is when foo2 has ben defined. If -bar was not dependent on -foo2 I could just do [CmdletBinding()] param ( [Parameter(Mandatory=$true)] [string]$foo1, [string]$foo2, [string]$bar ) However I do not know what to do to make that dependent parameter. 回答1: My reading of the original

Does powershell remoting support version of the powershell to be used on remote target?

被刻印的时光 ゝ 提交于 2019-11-29 13:05:13
Can I supply a version of powershell to be used on the target machine while ps remoting. May be my question is not proper or not possible to answer but if any body having idea please help me. I am trying to do a remoting using powershell on a machine where powershell 2.0 3.0 and 4.0 versions are available , but I want to use the version 4.0 only (on target machine) is it possible? Thanks Gyan Yes, there is a way to connect to a specific version of Powershell on a remote machine. It does require changes to be made on the remote machine though. When you use Powershell remoting to make a

How to work with Sharepoint cmdlet without installing sharepoint?

我的未来我决定 提交于 2019-11-29 11:38:40
I have to upload csv file fields into Sharepoint 2010 list using powershell. I am working in windows XP machine. When i am trying to add-pssnapin Add-PSSnapin Microsoft.SharePoint.Powershell It throws exception as "The Windows PowerShell snap-in 'Microsoft.SharePoint.Powershell' is not installed on this machine." Is it possible to work with Sharepoint Powershell cmdlet just by installing Pssnapin or by placing the necessary dlls in some location and load it? CB. I think the only way is to Enable-PSRemoting on Sharepoint server, then from XP computer: Enter-PSSession -ComputerName

Write-Progress for 10 Minutes PowerShell

此生再无相见时 提交于 2019-11-29 11:34:06
Hi all is there a way we can show progress bar for 10 minutes with statistics of percentage completed how much time remaining for 10 Minutes? using Write-Progress. If I understand the question correctly the goal is to show some additional information in the progress messages. This can be done for example by using the Activity parameter. The script below only shows the idea (for 1 minute, for a shorter test). It should be modified in order to reflect actually needed format of the message and information to be shown. $time = 60 # seconds, use you actual time in here foreach($i in (1..$time)) {

How can I use powershell's read-host function to accept a password for an external service?

扶醉桌前 提交于 2019-11-29 11:00:37
问题 I have a script I'm writing that makes a connection to a SOAP service. After the connection is made, I need to pass in a the username/pass with every command I send. The problem I have is that when I use read-host to do this, my password is shown in cleartext and remains in the shell: PS C:\Users\Egr> Read-Host "Enter Pass" Enter Pass: MyPassword MyPassword If I hide it with -AsSecureString, the value can no longer be passed to the service because it is now a System.Security.SecureString

Convert PowerShell script into non-readable format

孤人 提交于 2019-11-29 10:22:58
问题 I have a PowerShell script which installs a patch (contains set of files to be added) on a customer machine. For this, I have created a batch file which executes this PowerShell script. For the customer to run this batch file, the PowerShell script file must be placed onto the customer machine as well. The PowerShell script is in text format, which can be read and understood by the customer easily. Can we convert this script file into some non-readable format (e.g. bin or exe), so that it is