w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
Add Content in Powershell
There are two common ways for inserting text into a text file: Process the input file(s) line-by-line, write the output to a temporary file and replace the input file(s) with them temp file afterwards. for ($file in $files) { $filename = $file.FullName Get-Content $filename | % { if ( $_ -match 'seach pattern' ) { $_ "new line" } } | Out-File $tempfile MoveItem $tempfile $filename -Force } Read the entire content of the file(s), insert the text by using a regular expression replacement, and write the modified content back to the file(s). for ($file in $files) { $text = [System.IO.File]::ReadAllText($file.FullName) $text -replace '.*search pattern.*', "`$0`nnew line" | Out-File $file.FullName }

Categories : Powershell

Powershell. Get-content for every file
Your question isn't very clear, if you want to go though every file in the old directory and replace in the contents 'TEST-4' with a random number then output to a new directory then try this: Get-Childitem -Path .old -Filter *.edifact | % { Get-Content $_.FullName | % { $_ -Replace ('TEST-4', (Get-Random).ToString()) } | out-file (Join-Path '. ew' $_.Name) }

Categories : Powershell

Determine if webpage has content using PowerShell
1) Scrape Page You're off to a good start. The DownloadString method will download the HTML. 2) If content exists -> send email Depends on the content you are looking for. You can use the comparison operators -match or -like or string methods Contains() to test. Then put into an if/else block e.g. $string = $web.DownloadString("http://somewebsite") if ($string -match "regex_here") { Send-MailMessage -SmtpServer your_server -To to.address@domain -From from.address@domain -Subject foo -Body bar } else { # not necessary unless there is something you want to execute here. } Notice I used the Send-MailMessage cmdlet to send the email. 3) ELSE -> close. See above.

Categories : Powershell

Powershell - Replace XML content with an environment variable
You need to put the environment variable inside double quotes so it can be expanded. Single quoted strings are not expandable: ... -replace '<Password>(.*?)</Password>', "<Password>$env:HIS_PWD</Password>"

Categories : Xml

String replace file content with PowerShell
Use (V3 version): (Get-Content c: emp est.txt).replace('[MYID]', 'MyValue') | Set-Content c: emp est.txt Or for V2: (Get-Content c: emp est.txt) -replace '[MYID]', 'MyValue' | Set-Content c: emp est.txt

Categories : Powershell

PowerShell Get-Content and replace object in a specific line
Check if a line is starting with a 'Static Text ' followed by a sequence of word characters and return your string in case there a match: Get-Content $OptionsFile | foreach { if($_ -match '^Static Texts+(w+s)+') { 'Static Text MachineX MachineY' } else { $_ } }

Categories : Regex

Dynamically reading select XML content into Hashtable using Powershell
The issue is that you're calling the following: $securities.add=($i,$CUSIP,$Int_Rate,$Issue_Date,$Maturity_Date) The problem is with the equals sign there. What that actually does is insert a record with a key "add" with the rest of the values as the value. What you really want is to add a record with the key $i and a value of everything else. Try creating a [pscustomobject] of the rest of the values, and adding them to the hashtable, like so: $securities.add($i, [pscustomobject]@{'CUSIP'=$CUSIP;'Int Rate'=$Int_Rate;'Issue Date'=$Issue_Date';'Maturity Date'=$Maturity_Date}) EDIT: Try doing either of the following: ($securities.Jul_2012.xml).CUSIP or $securities['Jul_2012.xml'].CUSIP

Categories : Xml

Get-Content with wait parameter doesn't update in Powershell
Not allowed to comment (don't have a 50 reputation), so have to give an Answer.... Less for Windows (http://gnuwin32.sourceforge.net/packages/less.htm) with the +F or Shift-F option (http://www.commandlinefu.com/commands/view/1024/make-less-behave-like-tail-f.) showed updated file content where PowerShell "get-content $path -wait" did not.

Categories : Powershell

Powershell to output folder based on content lastwritetime
I am not completely sure, if I got your question right, but my little script shows all items, who have been changed in the last day and the time of change + the directory: $directories = (Get-ChildItem -Path C: est -Directory).FullName $directories | foreach {if (($_.lastwritetime -gt (get-date).adddays(-1)) -or ((get-childitem -path $_ -Recurse).lastwritetime -gt (get-date).adddays(-1))) { $itemname = (Get-ChildItem -Path $_ -Recurse | where {$_.LastWriteTime -gt (get-date).AddDays(-1)}).BaseName $itemtime = (Get-ChildItem -Path $_ -Recurse | where {$_.LastWriteTime -gt (get-date).AddDays(-1)}).LastWriteTime $_ >> C: imestamp.txt; $itemname >> C: imestamp.txt; $itemtime >> C: imestamp.txt;

Categories : Powershell

Why would installing Azure SDK 2.1 or powershell 3 on the build server break some of our tests which run in powershell?
Have you tried passing a fully qualified path to startInfo.FileName instead of just Powershell.exe incase there's a problem with %PATH% since the update Complete total guess, but any chance your running into FileSystemRedirector 32 vs. 64 issues as seen in this answer - Process.Start(): The system cannot find the file specified, but my file path seems to be legit

Categories : Powershell

Executing Powershell script as different User in Exchange 2007 Powershell
I just found out that executing Remote Powershell Commands/Skripts is not supported with Exchange 2007 (http://howexchangeworks.com/2009/11/exchange-2007-sp2-supports-powershell.html). So I need to wait until the upgrade to 2013. Some workarounds: http://social.technet.microsoft.com/Forums/en-US/exchangesvrgeneral/thread/4596035a-cede-4541-8b8e-e2e9bf1b40dc Or: http://peerfect.blogspot.co.at/2012/10/re-blog-of-my-exchange-remote.html

Categories : Powershell

Add Powershell Snapin for Powershell Module and Import Multiple Times
You might want to try to specify this module required by your own module through a module manifest (.psd1). See RequiredModules here.

Categories : Powershell

PowerShell Community Extensions not Recognized by TeamCity PowerShell Runner
Do you import the PSCX module in your script? PowerShell v3 will cache the module info after you have done this once so you don't need to import it again. However if TeamCity is running the 64-bit console and you normally run the 32-bit console, then the 64-bit console wouldn't have PSCX commands in the command cache. Anyway, it is a good practice to have your scripts explicitly require the modules it depends upon e.g. #requires -Modules Pscx

Categories : Powershell

How to use powershell variable in PowerShell.AddParameter method in C#?
The variable won't be available until you invoke the first script. Try this: ps.AddScript("$backupFile = [System.IO.Path]::Combine([System.IO.Path]::GetTempPath(),'{0}.bak')".FormatInvariant(databaseName)); ps.Invoke(); ps.Commands.Clear(); var backupFile = ps.Runspace.SessionStateProxy.PSVariable.Get("backupFile"); ps.AddCommand("New-Item") .AddParameter("Force") .AddParameter("ItemType", "File") .AddParameter("Path", backupFile )); ps.Invoke(); If you go this route though, I don't think you can use the RunspacePool because you're likely to get different runspaces between each Invoke(). In that case, the variable won't be available to the other runspace. Do you really need to use the RunspacePool in this scenario? If you do then why not just do the first bit in C#: var backup

Categories : C#

How do I return value or object from C# powershell command to Powershell
You have to use the CmdLet.WriteObject method. Here a good explanation from @RomanKuzmin.

Categories : Powershell

Powershell Script that will login into powershell for office 365
For the exchange powershell use: $SecPass1 = convertto-securestring -asplaintext -string "PasSword" -force $MSOLM = new-object System.Management.Automation.PSCredential -argumentlist "GlobalAdmin@some.com",$SecPass1 $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $MSOLM -Authentication Basic -AllowRedirection Import-Module MSOnline Import-PSSession $Session –AllowClobber

Categories : Actionscript

created a jquery tab content changer when tab content is increasing height due to inner content its over lapping to its bottom div
This happens because the wrapper of you content tabs .tab-container has height: 300px;. Put it to min-height: 300px; and should work fine. Test: JsFiddle

Categories : Jquery

Powershell Start-Process to start Powershell session and pass local variables
I'm pretty sure there's no direct way to pass variables from one PowerShell session to another. The best you can do is some workaround, like declaring the variables in the code you pass in -ArgumentList, interpolating the values in the calling session. How you interpolate the variables into the declarations in -ArgumentList depends on what types of variables. For an array and a string you could do something like this: $command = '<contents of your scriptblock without the curly braces>' Start-Process powershell -ArgumentList ("`$Array = echo $Array; `$String = '$String';" + $command)

Categories : Powershell

Unable to connect to Windows Azure from Powershell Azure Powershell module
To see is there some result from Import-AzurePublishSettingsFile you can call: Get-AzureSubscription By default it select the default to current subscription. If you don't see any result then you don't import your subscription settings right. This Introduction to Windows Azure PowerShell also can help you.

Categories : Windows

Invoke one PowerShell script from Another PowerShell script with passing arguments
PS C:> gc . est2.ps1 . est1.ps1 'foo' Write-Host 'bar' PS C:> gc . est1.ps1 $a = $ARGS[0] -split '' [array]::Reverse($a) Write-Host ($a -join '') PS C:> . est2.ps1 oof bar

Categories : Powershell

jQuery toggle slides DIV up and down, but UL content animates left to right. How can I make the content slide up and down?
toggle() simply toggles the showing/hiding, but doesn't specify how to show/hide. Try: $('#myMenu ul').slideToggle('slow'); jsfiddle

Categories : Jquery

Load content with Javascript, but still retain a unique link to specific content pages
What you want to achieve seems more like a Single Page Application. There are javascript libraries which can help you build the application the way you described it. Take a look on Sammy.js or History.js libraries.

Categories : Javascript

Cross-domain AJAX withCredentials, PHP returns header content-lenght, but no content
When setting headerAccess-Control-Allow-Credentials to true, you cannot use a wildcard for header Access-Control-Allow-Origin. That is, a specific host must be specified. Instead of: Access-Control-Allow-Origin: * Use: Access-Control-Allow-Origin: http://safedomain.com You can even set the Access-Control-Allow-Origin header to the Origin header received in the request. Not sure about PHP, but using the Java Servlets API: String origin = request.getHeader("Origin"); request.setHeader("Access-Control-Allow-Origin", origin);

Categories : PHP

Setting appropriate HTTP Content-Length header in WSGI middleware after manipulating content
You dont need to worry about deleting/adding/changing content-length header, that will be auto handled by the server when it sends out the response. Sending a wrong length header might create problems for your website viewers / internet browsers. You can test the Content-length headers here - http://www.dekho-ji.com/website-diagnostics-curl-http-request-response-headers-online

Categories : Python

HTTP Content-Encoding: gzip not recognized and wrong Content-Length
Oh god, I got it working! I dont' know why, but today I booted into my Windows development machine instead of Ubuntu. As it seems, Chrome for Windows doesn't display or process the response correctly. Under Ubuntu, it works at the first try. I want 6 hours of my life back.

Categories : Node Js

How to show data (in front of every content) in div if content come in huge lines in jQuery?
I would do something like this: .data .status, .data .text { float: left; } .data .status { width: 25%; } .data .status span { display: block; } .data .text { width: 75%; } <section class='data'> <div class='status'><span>Changed</span></div> <div class='text'>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce condimentum blandit neque. Nulla facilisi. Sed ornare luctus nulla euismod tincidunt. Cras rhoncus semper mi vitae facilisis. Nulla facilisi. Aliquam feugiat quis dui sit amet pretium. Nunc et accumsan risus, non lobortis mi. Donec pulvinar lacus diam, eu feugiat tortor malesuada a. Aenean pretium quam mi, id tincidunt nulla posuere nec</div> </section> var $data = $('.data'); $data.each(function

Categories : Jquery

Drupal 7/Views - Showing similar content with the same tag(s) when adding a new piece of content
Views, similar_by_terms, similar and other modules provide that functionality. See how to create such a block with views at this article http://www.metachunk.com/blog/adding-related-content-view-drupal-7

Categories : Drupal

UIPickerView change content text size after loading content into picker
If I understood your question correctly, you may want to take a look at this answer. The strategy is basically to truncate (ellipsis) instead of font shrinking. Edit (based on comment) I would strongly advise against setting all text to the minimum font. Lets say you have elements as such: Pear Peach ok, so far these will fit your label perfectly, with a good font size. Now you add a longer item: Pear Peach Strawberry Pineapple and now all your items are a little bit smaller, but thats still readable, so it's acceptable. And then a huge item appears, such as: Pear Peach Strawberry Pineapple SomeKindOfExoticFruitThatHasAnIncredibleLongName which would make all items inside your picker become incredibly small, and difficult to read. But if you still want to go down that roa

Categories : IOS

How do you bind to a listbox.itemtemplate in a style's content template content control
In the ListBoxItem style add ContentTemplate="{TemplateBinding ContentTemplate}" <ContentControl Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"> <!-- style stuff--> </ContentControl>

Categories : Wpf

unable to set hidden field content from div html content on fullscreen iPad Mobile Safari
This is quite old, but after googling around to solve the same issue for me, I have not found a solution. Looks like some weird behaviour from iPad (easily reproducible, no way to fix, at least that I found): the target input field gets changed indeed, but the posted value is the original one (???) So just in case a workaround is useful to somebody, instead of applying the changes from the contenteditable div on form submit, I apply the changes whenever the div is changed (no on change event for contenteditable divs, so really it is done on blur event): <div id="editor_inline_core_body" class="inputbox editor-inline" contenteditable>[initial value here]</div> <input type="hidden" id="jform_core_body" name="jform[core_body]" value="[ initial value here]" /> <script>

Categories : HTML

How to allow cross domain content script on Firefox add-on without firing mixed content blocking errors
Specifying that permission will cause the Sandbox (worker in SDK internal terms, content script in documentation) to simply get a new XMLHttpRequest constructor, that has more than one principal (or "origin", if you like). This will only change how to same-origin-policy is evaluated, but not how security in general and mixed-content policies in particular are implemented. That is: You still cannot do a https to http XHR, as you noticed. There is no work around you can use in your content script. You could however message your main script to do the request and pass the result back (again via message passing) to the content script. Please file a bug. At the very least this limitation should be documented. Personally, I wouldn't be in favor of lifting it. Mixed-content is a security issue,

Categories : Javascript

in Backbone, is it possible to tell fetch that it if it reads content that is content-type:'text/plain' to read it as JSON
Backbone uses jQuery.ajax under the hood for the ajax requests. So you need to use the dataType: 'json' options to specify how jQuery should treat the response when you are calling fetch: yourCollection.fetch({ dataType: 'json' });

Categories : Backbone Js

How to design content blocks which render HTML content as tumblr does?
You are talking about template engines. There are many. See Wikipedia’s comparison of web template engines. For more about the concepts, see the article Web template system.

Categories : HTML

Replace content of a fragment and remove old content - Android aplication
I finally found a workaround, I solved the problem like this: TabFavorites tabFavorites = (TabFavorites) getSupportFragmentManager().findFragmentById(R.id.pager); tabFavorites.reloadFavChannels();

Categories : Java

Why in HTML and JavaScript, if the content is being scrolled up and down, the content does not get a scroll event?
is the phrase "div B is being scrolled up and down" not technically correct Yes, that phrase is wrong, because in your case div A is being scrolled (this div has scrollbars). Even better is to say that the content canvas of div A is being scrolled and it doesn't matter what is placed on that canvas. It's like humans (div B) on the Earth (div A). The planet is moving/rotating like crazy but nobody feels that (no event received). :)

Categories : Javascript

Magnific popup closes on content click after replacing content
You need to call the HandleItemFormSubmit for the popup object: HandleItemFormSubmit.call(popup); Otherwise when you call it the way you do, HandleItemFormSubmit();, the this will be set to window and this will not work as expected. Update Use this in the else clause: if (resp == 'OK') { popup.close(); } else { // Show HTML from response (with errors) popup.closeOnContentClick = false; popup.content.replaceWith(resp); popup.updateItemHTML(); HandleItemFormSubmit.call(popup); }

Categories : Javascript

How to replace div's content by partial view or update it's content depending on what json result returns on ajax complete?
I had to solve this problem once so very long ago. I came up with a simple solution, which today, may not be the best solution but it gets the job done. My solution involved setting up a controller action that would render just the partial with data that it would need and have my JavaScript request it. C# MyController: Controller { public ActionResult GetPartialViewAction() { return PartialView("mypartialview", new partialViewModel()); } } JavaScript $.ajax({ url: "/my/getpartialaction/" }).done(function() { $("#partialViewDiv").html(data); }); HTML <div id="partialViewDiv"></div> A better solution would be to use a MVVM/MVC JavaScript library that would allow you to leverage html templates and only have to transmit the data over your ajax solution. I

Categories : C#

twig - render xml content with loops (even empty content)
Take a look at the FOSRestBundle in combination with the JMSSerializerBundle

Categories : Xml

Updating content when using Apple-hosted content for In-App Purchase
I spoke to some Store Kit engineers at WWDC and asked them this question. Their response wasn't as positive as I'd hoped. They confirmed the absence of an API for restoring a single product as a bug, and encouraged me to file two bugs (one for a enhancement request for that API in store kit and another for the documentation being too sparse around this area of upgrading products). As for the immediate problem, their suggestion was to either implement an "update all" feature, in which all products are restored in order to get their transactions and their download objects (the option I ultimately chose), or similarly, restore all products, but ignore all products except the one you're trying to update (pointless, ultimately, since you're restoring everything multiple times if you follow t

Categories : IOS

XNA Content Build Output not refreshed until all content is built
this works for me - context.Logger.LogImportantMessage(...); but for anything complex you will need to debug the build... this is one way.... System.Diagnostics.Debugger.Launch(); http://blogs.msdn.com/b/shawnhar/archive/2006/11/08/debugging-the-content-pipeline.aspx The way I prefer (actually I prefer not to have to debug the content pipeline), but when I must: I open up a new instance of visual studio open up the file in whichI wish to place a breakpoint place the break point attach this instance of VS to the other (proper) instance of VS When I then compile/build the breakpoint will be hit Hope this helps.

Categories : C#



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.