Tuesday, December 18, 2012

Run powershell in windows batch file

I needed to run a powershell script in batch file so it would be executed as one line of commands, without requiring to run .ps1 file directly.
The task is fairly simple, I've done this before. But this time I ran into another problem, because the need of using " signs inside " signs that were actually around -command argument.
This leaded me to a problem that I couldn't use escape chars for " because it would escape it from script altogether.
I couldn't use ' signs either, because that would turn variable names into direct strings.

Here is what I had at start (works within powershell):

$date = Get-Content '.\card_dates.txt' | Select-Object -last 1;
Get-ChildItem '.\sql' -Exclude '*.parsed' | ForEach-Object ($_) {
   Get-Content $_.FullName | Foreach-Object {
      $_ -replace '#PARAM_1', $date
   } | Set-Content "$($_.FullName).parsed"
}

Here is the modification that gave me the error (if running from batch):

powershell -Command "& { $date = Get-Content '.\card_dates.txt' | Select-Object -last 1; Get-ChildItem '.\sql' -Exclude '*.parsed' | ForEach-Object ($_) { Get-Content $_.FullName | Foreach-Object {$_ -replace '#PARAM_1', $date} | Set-Content "$($_.FullName).parsed" } } "

This is the error:

Set-Content : Cannot bind argument to parameter 'Path' because it is null.
At line:1 char:222
+ ...  | Set-Content $($_.FullName).parsed } }
+                    ~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Set-Content], ParameterBinding
   ValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,M
   icrosoft.PowerShell.Commands.SetContentCommand

So what did I change to make it work?
The solution was actually really simple.
Instead of using:
"$($_.FullName).parsed"

I had to use:
$($($_.FullName) + '.parsed')

And here is the solution that works directly from commandline

powershell -Command "& { $date = Get-Content '.\card_dates.txt' | Select-Object -last 1; Get-ChildItem '.\sql' -Exclude '*.parsed' | ForEach-Object ($_) { Get-Content $_.FullName | Foreach-Object {$_ -replace '#PARAM_1', $date} | Set-Content $($($_.FullName) + '.parsed') } } "

What this script does?
  1. Read last line from textfile (it is populated there by other scripts)
  2. Read all SQL files inside SQL folder
  3. Withing every file, change #PARAM_1 to be the last line from textfile
  4. Save the file with .parsed extension
Basically we have templates for SQL sentences and historically all the jobs run as BATCH files.
I'm better with Powershell so I wanted to do it in powershell but at the same time keep the old BATCH-es.

Hopefully this information is a bit helpful for you, I spent quite some time to figure out the simple solution.

Thursday, November 8, 2012

Surface Pro details leaked

Although the RT version of Microsoft’s first tablet ever is already experiencing record sales, there’s no doubt that most people are actually expecting the Surface Pro. 

And the reason is as simple as it could be: it will be able to run legacy Windows programs and won’t be limited to RT apps like the currently available Surface.


Microsoft hasn’t provided too much info on the Surface Pro, but German retailer Notebook.de has recently unveiled pricing for the device and even kicked off a pre-order campaign for local buyers.


The Surface Pro will come equipped with the actual Windows 8 operating system and will pack more advanced hardware as compared to the RT. Sources close to the matter suggest that it’ll feature a larger battery, a higher resolution display and more storage space, most likely up to 128 GB.


The German retailer lists two different Surface Pro versions, one with 128 GB and the other one with 64 GB of storage space.


Hardware information is still limited, but the 128 GB model is priced at $1165 (€909), while the 64 GB version is a bit cheaper – $1035 (€809). Since it’s a European Union state, Germany also has a Value Added Tax (VAT), so the device is going to be cheaper in the United States.


US buyers will be able to get the Surface Pro with 128 GB of storage space for $975 (€763) and the 64 GB flavor for $870 (€679).


While the Surface Pro is going to be a bit heavier than the Surface RT, it’ll provide a full Windows 8 experience. The device will be delivered with a stylus and will boast 4 GB of RAM to better handle the operating system and the installed apps. An Intel Core i5 processor is very likely to be installed on all Surface Pro versions.


The Surface Pro will be heavier than the Surface RT, but it'll be able to run legacy Windows app. The device is expected to be released in early 2013.

Here are the technical specs provided by Notebook.de, but we cannot guarantee that all of these are indeed accurate. Microsoft is yet to issue a comment on the matter, but we’ve contacted the Redmondians and we’ll get back to you as soon as we receive an answer. The technical specification list provided by Microsoft is available here (PDF viewer needed).

- 10.6-inch full HD ClearType display
- 1920x1080 resolution
- Intel Core i5 processor
- 4 GB of RAM
- 128 GB / 64 GB of storage space
- Intel HD 4000 video card
- 802.11 a/b/g/n wireless card
- Bluetooth 4.0
- HD camera
- Vapor Magnesium case
- Total weight – 900g


Anticipating :)

Sunday, October 28, 2012

Surface tablet keynote

If you missed the keynote then now you have the chance to check it out. I am personally quite impressed about the touch cover, which I didn't like from the pictures. The overall quality of the device seems superb, I love how thorough Microsoft has been when developing this product.
But does the RT version come with desktop mode also or are the ones in the end of demo pro versions?
I thought it will be unavailable on RT.
My next PC will be surface :)


Friday, October 19, 2012

Google data centers revealed

Now you can have peek inside those mysterious data centers that Google has built. Seems like they have a deal with Stormtroopers to guard their data. Scroll down for a video!


10. Georgia, USA

These colorful pipes send and receive water for cooling our facility. Also pictured is a G-Bike, the vehicle of choice for team members to get around outside our data centers.

9. Iowa, USA

Our Council Bluffs data center provides over 115,000 square feet of space. We make the best out of every inch, so you can use services like Search and YouTube in the most efficient way possible.

8. Georgia, USA

Blue LEDs on this row of servers tell us everything is running smoothly. We use LEDs because they are energy efficient, long lasting and bright.

7. Iowa, USA

Inside our campus network room, routers and switches allow our data centers to talk to each other. The fiber optic networks connecting our sites can run at speeds that are more than 200,000 times faster than a typical home Internet connection. The fiber cables run along the yellow cable trays near the ceiling.

6. Oklahoma, USA

A rare look behind the server aisle. Here hundreds of fans funnel hot air from the server racks into a cooling unit to be recirculated. The green lights are the server status LEDs reflecting from the front of our servers.

5. Iowa, USA

Hovering above the floor in Council Bluffs, Iowa, the scale of our data center there begins to take shape. Huge steel beams both support the structure and help distribute power.

4. Georgia, USA

Thousands of feet of pipe line the inside of our data centers. We paint them bright colors not only because it's fun, but also to designate which one is which. The bright pink pipe in this photo transfers water from the row of chillers (the green units on the left) to a outside cooling tower.

3. Mayes County, Oklahoma

Each of our server racks has four switches, connected by a different colored cable. We keep these colors the same throughout our data center so we know which one to replace in case of failure.

2. The Dalles, Oregon

In an unoccupied area, motion-sensors automatically switch off the main lighting to save power. The result is the dazzling glow of the world's data filtered through multicolored LEDs. It's like holiday lights year-round.

1. Hamina, Finland

Server floors like these require massive space and efficient power to run the full family of Google products for the world. Here in Hamina, Finland, we chose to renovate an old paper mill to take advantage of the building's infrastructure as well as its proximity to the Gulf of Finland's cooling waters.

Video 


Google Chromebook released


Google Chromebook by Samsung

Have you already seen the launch announcement of a new product by Google?
There is a new product on the market - the Chromebook, tagged at 249$
This seems like a perfect product for your grandparents that need to edit only a few documents and do some internet surfing.

Here are the specs:


  • Model Number: XE303C12
  • Display Size: 11.6-inches
  • Display: 1366x768 resolution; 200nit brightness
  • Weight: 2.43 lbs (1.1.kg)
  • Less than 0.8 inches thick (17.5 mm)
  • Battery Life: over 6.5 hours
  • Processor: Samsung Exynos 5250
  • Memory: 2GB
  • Storage: 16GB SSD (Google is including 100GB free online storage)
  • Webcam
  • Ports: 1 USB 3.0, 1 USB 2.0, combo headphone/mic jack, secure digital memory slot
  • HDMI Port
  • Bluetooth 3.0™ Compatible
  • Speaker: 1.5W speaker X 2
  • Keyboard: Full-size Chrome keyboard
  • Wireless: 802.11 abg/n 2x2
  • MSRP: $249 USD / 229 GBP



And here you can see the Chromebook being used by one of the Google employees.

Google earnings Q3 2012


Did you know about Google's this years Q3 earnings? They topped at $14.10 billion in revenue, $2.74 billion in operating income.

A great slogan for Apple fanboys and -girls


Wednesday, October 17, 2012

Microsoft Surface with WinRT prices revealed


Well, the day has come, pre-ordering of Microsoft Surface is open and the prices have been revealed.
To be honest, I'm a bit disappointed in the prices. In this article we look into US prices.
Don't be fooled, these devices are bundled with WinRT version and have ARM processor and no real PC power nor access to desktop programs or desktop itself, like Windows users have today.
For the real PC tablets we have to wait probably until next year 1st or 2nd quarter.


How much do they cost?


Only the 32gb tablet without any extras would be 499$. To get the "touch" cover for it you have to pay extra 100$
Now if you are not into touch keyboard cover and want to go with real typing keyboard cover then replace latter with 120$ (or 130$ for black model that matches your tablet color).
Probably you want a cover anyway so you basically can choose between 599$ tablet with touch keyboard or 619$ or 629$ with real typing keyboard (depending on your color preference).
I strongly believe that it is still a good to have an option to buy the tablet without the cover (developers clap their hands for this)

What about the storage options?

The metro programs are quite small (because there are no super-duper HQ programs yet in MS Store). But if you think about it, 32gb is probably not enough to store your movies and music. Probably you would like to double the storage and go with 64gb version which costs 699$ (and comes with the touch cover).
That's 100$ extra on top of the 599$ device. Isn't that a lot of money for extra 32gb?
Let's compare... If the devices have SSD inside, you can get 120gb laptop SSD drive from amazon right now, if you want to compare. If you sum 32gb with 120gb you get 150gb.
There are no other options besides 32 and 64 gigabytes right now.


All these prices are for US. In United Kingdom, the 699$ model would cost over 900$ (if converted).


What could be better?


To beat Apple's iPad, I think the options provided will not be sufficient and the Surface will remain in shelves until the prices drop or something get's better than iPad (For example if the tablet is equivalent to regular PC by processor and/or operating system).

They would have to come out with a lot better options like:

  • 32gb version (no cover) for super cheap price like 300$ or less (for devs to make more apps)
  • 64gb retail version with cover for 449$
  • 120gb top notch version with cover for 649$
Also, there should be more color options for personalizing the experience (Probably will happen after general availability)
The platform has not proved itself yet and it is quite hard to do so with no decent customer base and programs in the store.
I really like the concept of Windows 8, Windows phone 8 and Metro for touch devices but the high priced hardware provided is not helping this technology to get into the masses...
I would like to go with the cheapest option myself and start experimenting with the platform because there is no real reason why to buy Surface right now. There are no really useful apps for Metro (besides those bundled by Microsoft, but I can access my calendar, mail, IM and other stuff like that even without this tablet).

Pre-Order now!

If you are interested in pre-ordering this great (but high priced) device and live in the US - click here
For other countries - click here (Expect even more higher prices than US)

More information and a video about the Surface


What do you think about the device itself or the pre-order pricing? Leave a comment!