powershell-3.0

Remove leading zeros in csv file from int values only

老子叫甜甜 提交于 2019-12-02 05:40:45
问题 I have this csv file I'm trying to remove leading zeros from, but with my code for any numbers that have letters or special characters, it nulls out the value, and I don't want that... column1 ,column2 ,column3 ,column4 ,column5,column6,column7,column8 ,column9,column10,column11,column12,column13 ,column14,column15,column16 0000013 , ,ShopKeep ,Store , , , , , ,1034627 , , , , , , 0000032 , ,Test411 ,User411 ,0007643, , , , ,1034632 , , , , , , 0000142 , ,Pinky ,Brain ,0571253, , , ,J ,1234 ,

How to queue another TFS (2012) Build from a TFS Build AND pass process parameters?

試著忘記壹切 提交于 2019-12-02 05:14:23
The product I work on comprises 3/4 seperate (non-dependant) TFS builds. I would like to create a single TFS build which queues the other 3/4 builds from within the ProcessTemplate AND, critically, pass process parameters to them. This build would wait for them all to complete and return an overall success/failure of the build. So my questions are: Can this be achieved by any existing 'standard' Workflow activities (my manager has had bad experiences with custom workflow activities)? If not, I am able to 'shell out' to powershell. Can I achieve what I want from within Powershell (accessing the

Getting error “Changing property 'osDisk.name' is not allowed.” with Azure Powershell Script

核能气质少年 提交于 2019-12-02 05:04:23
问题 I'm trying to move an existing Azure VM with a Managed Disk into an existing Availability Set. However, when I apply the command: New-AzureRmVM -ResourceGroupName $rg -Location $OriginalVM.Location -VM $NewVM -DisableBginfoExtension I get the following error: New-AzureRmVM : Changing property 'osDisk.name' is not allowed. ErrorCode: PropertyChangeNotAllowed ErrorMessage: Changing property 'osDisk.name' is not allowed. StatusCode: 409 ReasonPhrase: Conflict OperationID : c179070b-e189-4025

Adding a complete directory to an existing zip file with System.IO.Compression.FileSystem

喜夏-厌秋 提交于 2019-12-02 04:18:52
The following example is retraceable on the internet and on this website as a sollution to compress files using the .NET Framework 4.5 It works, but when the archive already exists it will give an error, as it only seems to be able to zip a folder and create a new zip file: [Reflection.Assembly]::LoadWithPartialName( "System.IO.Compression.FileSystem" ) $src_folder = "D:\stuff" $destfile = "D:\stuff.zip" $compressionLevel = [System.IO.Compression.CompressionLevel]::Optimal $includebasedir = $false [System.IO.Compression.ZipFile]::CreateFromDirectory($src_folder,$destfile,$compressionLevel,

Conditional replace in XML files

拜拜、爱过 提交于 2019-12-02 04:17:09
I'm replacing a text in XML files recursively using PowerShell. The script is working fine in replacing. However the XML files also have file paths which should not be replaced. This is the script currently being used if ( $content -match ' web site | web-site ' ) { $content -replace ' web site ',' New Site ' -replace ' web-site ',' New Site ' | Out-File $file.FullName -Encoding utf8 For example if the XML file has <title>web site</title> <subtitle>web-site</subtitle> <path>c:/web site/website.xml</path> the expected output is should look like below. The matching text in file paths should be

How to Remove Special/Bad Characters from XML Using Powershell

核能气质少年 提交于 2019-12-02 03:09:52
I have an XML Files and I want to remove those Hexadecimal Characters Errors from the file below is the invalid characters: I don't know what does STX means and when i tried copying it to my clipboard and paste it in MS Work it shows some other value. How can I write a script in powershell to remove the above from my XML file. The following regex will remove any invalid characters from XML by specifying a character class negating the entire set of valid unicode entries in an XML document: $rPattern = "[^\x09\x0A\x0D\x20-\xD7FF\xE000-\xFFFD\x10000\x10FFFF]" $xmlText -replace $rPattern,'' This

Getting error “Changing property 'osDisk.name' is not allowed.” with Azure Powershell Script

元气小坏坏 提交于 2019-12-02 02:25:40
I'm trying to move an existing Azure VM with a Managed Disk into an existing Availability Set. However, when I apply the command: New-AzureRmVM -ResourceGroupName $rg -Location $OriginalVM.Location -VM $NewVM -DisableBginfoExtension I get the following error: New-AzureRmVM : Changing property 'osDisk.name' is not allowed. ErrorCode: PropertyChangeNotAllowed ErrorMessage: Changing property 'osDisk.name' is not allowed. StatusCode: 409 ReasonPhrase: Conflict OperationID : c179070b-e189-4025-84b0-87ba748f5844 At line:2 char:5 + New-AzureRmVM -ResourceGroupName $rg -Location $OriginalVM.Locati ...

Is it possible to attach an event to a PSObject?

允我心安 提交于 2019-12-02 01:59:13
Say I've a psobject like this : $o=New-Object PSObject -Property @{"value"=0} Add-Member -MemberType ScriptMethod -Name "Sqrt" -Value { echo "the square root of $($this.value) is $([Math]::Round([Math]::Sqrt($this.value),2))" } -inputObject $o Is it possible to attach an event so that the method Sqrt() is executed when the value attribute change ? ie : PS>$o.value=9 will produce the square root of 9 is 3 update As per @Richard answer this is the working recipe : $o=New-Object PSObject -property @{"_val"=1} Add-Member -MemberType ScriptMethod -Name "Sqrt" -Value { write-host "the square root of

Trying to download a zip file from a weblink with powershell

隐身守侯 提交于 2019-12-02 00:36:09
Ok, I am trying to download a file off of a web link that we use with powershell. I am downloading a zip file where the begining of the name is always the same, but the the middle part will change based off of the version number of the zip. I have been able to get the file to download when I use the fully qualified web address and have the file name hard coded into the script. I have tried every version of using the wild cards to get all the most common version of the zip, but it errors out saying that it can't find the file on there server. This is the code that I have already, and any help

Remove leading zeros in csv file from int values only

偶尔善良 提交于 2019-12-02 00:24:28
I have this csv file I'm trying to remove leading zeros from, but with my code for any numbers that have letters or special characters, it nulls out the value, and I don't want that... column1 ,column2 ,column3 ,column4 ,column5,column6,column7,column8 ,column9,column10,column11,column12,column13 ,column14,column15,column16 0000013 , ,ShopKeep ,Store , , , , , ,1034627 , , , , , , 0000032 , ,Test411 ,User411 ,0007643, , , , ,1034632 , , , , , , 0000142 , ,Pinky ,Brain ,0571253, , , ,J ,1234 , , , , , , 0000145 ,Leo@ninjaturtles.com ,Leo ,Turtle ,0661203, , , ,J ,2345 , , ,RNixon , , , 0000264