background preloader

Powershell

Facebook Twitter

Windows 7 - Run an application with PowerShell and wait until it is finished. Integrating Microsoft Excel with PowerShell: Basic Reports. By Jeff Hicks - March 15, 2012 Not too long ago I wrote about Integrating Microsoft Word with PowerShell, but I know that after text files, the most used tool for Windows administration is Microsoft Excel.

Integrating Microsoft Excel with PowerShell: Basic Reports

Based on what I see in forums and talking with people at conferences, there is a lot of information tucked away in Excel spreadsheets. There's no shortage of people who want to save information to Excel or read from it. Normally, I tell people that if they are using PowerShell, they can simply export results to a CSV file and then open that in Excel, but perhaps you really need an Excel file. Is there a faster way to parse an excel document with Powershell. How Can I Use Windows PowerShell to Delete All the .TMP Files on a Drive? - Hey, Scripting Guy! Blog. Hey, Scripting Guy!

How Can I Use Windows PowerShell to Delete All the .TMP Files on a Drive? - Hey, Scripting Guy! Blog

How can I use Windows PowerShell to locate and delete all the .tmp files on a drive? -- OR Hey, OR. You know, there’s an old saying: Give a man a fish and he’ll eat for a day; teach that man to fish and he’ll eat for the rest of his life. Well, unless he’s like the Scripting Guy who writes this column and doesn’t like seafood. Yes, it is. The point is – well, to tell you the truth, we’re no longer sure what the point is. In other words, if you’re interested in Windows PowerShell then you owe it to yourself to attend Windows PowerShell Week, November 6-10, 2006. Well, that’s a good point: you never know what Peter will do during a webcast, do you? So, other than fishing, what kinds of things will you learn during Windows PowerShell Week? Grep - How do I output lines that do not match 'this_string' using Get-Content and Select-String in PowerShell. Modular Scripting in PowerShell.

Each one of us has our own style in the way we accomplish tasks, scripting is no different.

Modular Scripting in PowerShell

My style is modular scripting; where I build libraries of functions (code blocks) and control script flow by calling functions in the order I choose. By maintaining a large library of user-defined functions (custom functions), I “snap-in” new functionality within my PowerShell scripts, with ease. I’m also a firm believer that cleanliness is next to Script-Godliness. PowerShell scripts should be well written so that other administrators can easily understand and follow your code.

Using a template, which I’ve provided below, is a great way to organize your scripts. Script Template. Powershell script for prepending and appending text. Les bases de PowerShell. Séquences d’échappement Le caractère d’échappement Windows PowerShell est l’accent grave (`).

Les bases de PowerShell

Pour rendre un caractère littéral, faites-le précéder de `. Séquences d’échappement spéciales Méthodes de traitement d’objets Ces méthodes permettent de traiter des objets. Ou moins utile, connaitre la position du premier « l » dans « Hello ». Méthodes pour le traitement d’objets. Variables automatiques Chaînes. Comparing Python and PowerShell DBA Scripting. I became interested in scripting about a year or two ago when I landed a DBA job in a larger shop that was primarily focused on production support and Database Change Management.

Comparing Python and PowerShell DBA Scripting

I was assigned several projects, each of which had at least three servers, Dev, QA, and Prod. It quickly became apparent to me that keeping up with all the typical daily DBA tasks would require some automation. I had compiled an extensive set of SQL scripts to help with my daily tasks and I had dabbled with VBScript but it didn’t quite get my juices flowing. So, I continued searching, trying Perl and then Python, which I had tinkered with at home on a Linux box. I ended up deciding on Python, mostly because of its clean syntax which makes it really easy to read. Topic: replace special characters. By willbs at 2013-04-06 11:52:14 by coderaven at 2013-04-06 12:46:49 Let me see if I can answer your first question.

Topic: replace special characters

Doing a little looking, the -replace is a nice feature but may not be the best with the "[" items in the string if it is producing an error for you. Try just doing a .Net string replace method call.Get-ChildItem "H:\MUSIC\" -Recurse | ` Where-Object {$_.Name -match '_' } | ` Rename-Item -NewName ([string]$_.Name).Replace("_", "-"))Also, be careful using $_ and 2 |'s in a row maybe use a foreach loop. PowerShell commands. How do I use Powershell to join rows (lines) from a text file to create only one line? 10 fundamental concepts for PowerShell scripting. PowerShell can save you a lot of time on Windows admin tasks -- but to use it effectively, you need to understand how it works.

10 fundamental concepts for PowerShell scripting

Here's a crash course in PowerShell basics to get you started. PowerShell scripts offer a handy way to automate various chores. Here are some key concepts that will help beginners as they start developing PowerShell scripts. Note: This article is also available as a PDF download. Windows PowerShell: Du beau boulot. Windows PowerShellDu beau boulot Don Jones Il n'est pas rare de souhaiter que des scripts produisent un résultat attrayant et l'on me demande souvent quelle est la meilleure façon de produire des choses telles que des tableaux.

Windows PowerShell: Du beau boulot

Il existe en fait deux façons d'y parvenir. La première étape consiste à écrire un script qui place les données que je souhaite afficher de façon formatée dans des variables appelées $data1, $data2 et $data3. La méthode texte En général, les gens tentent de réaliser cette tâche de la même façon que s'ils travaillaient dans un langage tel que VBScript, Perl, KiXtart ou un autre langage orienté texte. Write-Host "ColumnA'tColumnB'tColumnC" Notez que `t est une séquence d'échappement spéciale dans Windows PowerShellTM qui insère un caractère de tabulation.