<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>LeVeilleur.net &#187; Script</title>
	<atom:link href="http://www.leveilleur.net/index.php/tag/script/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.leveilleur.net</link>
	<description></description>
	<lastBuildDate>Thu, 03 Jun 2010 21:21:36 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>fr</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>PoshBoard : PowerShell into a DashBoard</title>
		<link>http://www.leveilleur.net/index.php/2009/02/20/poshboard-powershell-into-a-dashboard/</link>
		<comments>http://www.leveilleur.net/index.php/2009/02/20/poshboard-powershell-into-a-dashboard/#comments</comments>
		<pubDate>Fri, 20 Feb 2009 13:50:11 +0000</pubDate>
		<dc:creator>Christopher Keyaert</dc:creator>
				<category><![CDATA[powershell]]></category>
		<category><![CDATA[graphique]]></category>
		<category><![CDATA[poshboad]]></category>
		<category><![CDATA[Script]]></category>

		<guid isPermaLink="false">http://www.leveilleur.net/?p=166</guid>
		<description><![CDATA[Voici un projet très très prometteur.


PoshBoard 0.4 Techdays 2009 edition from 
Antoine Habert on 
Vimeo.

]]></description>
			<content:encoded><![CDATA[<p>Voici un projet très très prometteur.<br />
<center><br />
<object width="400" height="225"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=3286076&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=3286076&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="225"></embed></object><br />
<a  href="http://vimeo.com/3286076" onclick="javascript:pageTracker._trackPageview('/external/vimeo.com/3286076');" >PoshBoard 0.4 Techdays 2009 edition</a> from 
<a  href="http://vimeo.com/user301430" onclick="javascript:pageTracker._trackPageview('/external/vimeo.com/user301430');" >Antoine Habert</a> on 
<a  href="http://vimeo.com" onclick="javascript:pageTracker._trackPageview('/external/vimeo.com');" >Vimeo</a>.<br />
</center></p>
]]></content:encoded>
			<wfw:commentRss>http://www.leveilleur.net/index.php/2009/02/20/poshboard-powershell-into-a-dashboard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PowerShell : Control Excel</title>
		<link>http://www.leveilleur.net/index.php/2009/02/03/powershell-control-excel/</link>
		<comments>http://www.leveilleur.net/index.php/2009/02/03/powershell-control-excel/#comments</comments>
		<pubDate>Tue, 03 Feb 2009 21:16:06 +0000</pubDate>
		<dc:creator>Christopher Keyaert</dc:creator>
				<category><![CDATA[powershell]]></category>
		<category><![CDATA[Control]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[Script]]></category>

		<guid isPermaLink="false">http://www.leveilleur.net/?p=143</guid>
		<description><![CDATA[Voici quelques bouts de code pour controler Microsoft Excel à partir de PowerShell
#Creation of the xls Sheet

$a = New-Object -comobject Excel.Application
$a.visible = $True

$MyWorkBook = $a.Workbooks.Add()
$MyWorksheets = $MyWorkBook.Worksheets.Item(1)
$i=1;

$MyWorksheets.Cells.Item(1,$i++) = "Server Name"
$MyWorksheets.Cells.Item(1,$i++) = "Host"
$MyWorksheets.Cells.Item(1,$i++) = "Cluster"

#Excel Sheet Format
$d = $MyWorksheets.UsedRange
$d.Interior.ColorIndex = 19
$d.Font.ColorIndex = 11
$d.Font.Bold = $True

$MyWorksheets.Cells.Item($intRow,$i++) = "OK"
$MyWorksheets.Cells.Item($intRow,$i-1).Interior.ColorIndex = 4

#Save the XLS page in CSV
$FileFormat=[Microsoft.Office.Interop.Excel.xlFileFormat]::xlCsv
if(test-path "$FileLocation\BocadaExport.csv"){Remove-Item "$FileLocation\BocadaExport.csv"}
$MyWorksheets.SaveAs("$FileLocation\BocadaExport.csv",$FileFormat)

#Quit [...]]]></description>
			<content:encoded><![CDATA[<p>Voici quelques bouts de code pour controler Microsoft Excel à partir de PowerShell</p>
<pre>#Creation of the xls Sheet

$a = New-Object -comobject Excel.Application
$a.visible = $True

$MyWorkBook = $a.Workbooks.Add()
$MyWorksheets = $MyWorkBook.Worksheets.Item(1)
$i=1;

$MyWorksheets.Cells.Item(1,$i++) = "Server Name"
$MyWorksheets.Cells.Item(1,$i++) = "Host"
$MyWorksheets.Cells.Item(1,$i++) = "Cluster"

#Excel Sheet Format
$d = $MyWorksheets.UsedRange
$d.Interior.ColorIndex = 19
$d.Font.ColorIndex = 11
$d.Font.Bold = $True

$MyWorksheets.Cells.Item($intRow,$i++) = "OK"
$MyWorksheets.Cells.Item($intRow,$i-1).Interior.ColorIndex = 4

#Save the XLS page in CSV
$FileFormat=[Microsoft.Office.Interop.Excel.xlFileFormat]::xlCsv
if(test-path "$FileLocation\BocadaExport.csv"){Remove-Item "$FileLocation\BocadaExport.csv"}
$MyWorksheets.SaveAs("$FileLocation\BocadaExport.csv",$FileFormat)

#Quit XLS
$excel.displayalerts = $False
$excel.quit()</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.leveilleur.net/index.php/2009/02/03/powershell-control-excel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PowerShell : Control IE</title>
		<link>http://www.leveilleur.net/index.php/2009/02/03/powershell-control-ie/</link>
		<comments>http://www.leveilleur.net/index.php/2009/02/03/powershell-control-ie/#comments</comments>
		<pubDate>Tue, 03 Feb 2009 21:12:19 +0000</pubDate>
		<dc:creator>Christopher Keyaert</dc:creator>
				<category><![CDATA[powershell]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[Script]]></category>

		<guid isPermaLink="false">http://www.leveilleur.net/?p=141</guid>
		<description><![CDATA[Voici quelques bouts de code PowerShell permettant le control d&#8217;Internet Explorer
#Rune IE
$ie = new-object -com "InternetExplorer.Application"
$ie.visible = $true
$ie.navigate('http://mypage.com')

#Authentication on the web page
while($ie.busy) {start-sleep 1}
if ($ie.document.getElementByID("FormUsername") -ne $null)
    {
    $ie.document.getElementByID("FormUsername").value = "myLogin"
    $ie.document.getElementByID("FormPassword").value = "MyPwd"

    #Click on the button for logon
    $forms = @($ie.Document.forms &#124; where {$_.action -match "VerifPwd.htm"})
    $forms[0].submit()
    while($ie.busy) {start-sleep 1}
    }

$ie.navigate('http://mypage.com/page2.html')
while($ie.busy) {start-sleep 1} [...]]]></description>
			<content:encoded><![CDATA[<p>Voici quelques bouts de code PowerShell permettant le control d&#8217;Internet Explorer</p>
<pre>#Rune IE
$ie = new-object -com "InternetExplorer.Application"
$ie.visible = $true
$ie.navigate('http://mypage.com')

#Authentication on the web page
while($ie.busy) {start-sleep 1}
if ($ie.document.getElementByID("FormUsername") -ne $null)
    {
    $ie.document.getElementByID("FormUsername").value = "myLogin"
    $ie.document.getElementByID("FormPassword").value = "MyPwd"

    #Click on the button for logon
    $forms = @($ie.Document.forms | where {$_.action -match "VerifPwd.htm"})
    $forms[0].submit()
    while($ie.busy) {start-sleep 1}
    }

$ie.navigate('http://mypage.com/page2.html')
while($ie.busy) {start-sleep 1} 

#Exit IE
$ie.quit()</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.leveilleur.net/index.php/2009/02/03/powershell-control-ie/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PowerShell : Encrypt Password in text file</title>
		<link>http://www.leveilleur.net/index.php/2009/02/03/powershell-encrypt-password-in-text-file/</link>
		<comments>http://www.leveilleur.net/index.php/2009/02/03/powershell-encrypt-password-in-text-file/#comments</comments>
		<pubDate>Tue, 03 Feb 2009 21:07:59 +0000</pubDate>
		<dc:creator>Christopher Keyaert</dc:creator>
				<category><![CDATA[powershell]]></category>
		<category><![CDATA[encrypt]]></category>
		<category><![CDATA[password]]></category>
		<category><![CDATA[Script]]></category>

		<guid isPermaLink="false">http://www.leveilleur.net/?p=139</guid>
		<description><![CDATA[Hello tout le monde,
Voici un petit bout de code PowerShell vous permettant de crypter les mots de passes que vous utilisez dans vos scripts.
read-host -prompt "Enter password to be encrypted in file.pwdt " -assecurestring &#124; convertfrom-securestring &#124; out-file file.pwd

$pass = cat file.pwd &#124; convertto-securestring
$ptr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($pass)
$pass_back = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($ptr)

write-output "password decrpyted is: $pass_back"
]]></description>
			<content:encoded><![CDATA[<p>Hello tout le monde,</p>
<p>Voici un petit bout de code PowerShell vous permettant de crypter les mots de passes que vous utilisez dans vos scripts.</p>
<pre>read-host -prompt "Enter password to be encrypted in file.pwdt " -assecurestring | convertfrom-securestring | out-file file.pwd

$pass = cat file.pwd | convertto-securestring
$ptr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($pass)
$pass_back = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($ptr)

write-output "password decrpyted is: $pass_back"</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.leveilleur.net/index.php/2009/02/03/powershell-encrypt-password-in-text-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Scom2007 : Scripts pour Maintenance Mode</title>
		<link>http://www.leveilleur.net/index.php/2008/11/23/scom2007-scripts-pour-maintenance-mode/</link>
		<comments>http://www.leveilleur.net/index.php/2008/11/23/scom2007-scripts-pour-maintenance-mode/#comments</comments>
		<pubDate>Sun, 23 Nov 2008 16:41:21 +0000</pubDate>
		<dc:creator>Christopher Keyaert</dc:creator>
				<category><![CDATA[Scom 2007]]></category>
		<category><![CDATA[maintenance mode]]></category>
		<category><![CDATA[Operations manager]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[scom]]></category>
		<category><![CDATA[SCOM2007]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[System Center]]></category>

		<guid isPermaLink="false">http://www.leveilleur.net/index.php/2008/11/23/scom2007-scripts-pour-maintenance-mode/</guid>
		<description><![CDATA[Hello tout le monde,
En tant qu&#8217;utilisateur de Microsoft System Center Operations Manager 2007, vous avez déjà certainement été confronté au problème ci-dessous
 A computer agent unexpectedly generates heartbeat alerts after you put it into Maintenance mode in System Center Operations Manager 2007
La description détaillée de cela se trouve sur le site de Microsoft : 
http://support.microsoft.com/kb/942866
En fait, [...]]]></description>
			<content:encoded><![CDATA[<p>Hello tout le monde,</p>
<p>En tant qu&#8217;utilisateur de Microsoft System Center Operations Manager 2007, vous avez déjà certainement été confronté au problème ci-dessous</p>
<p><em><strong> A computer agent unexpectedly generates heartbeat alerts after you put it into Maintenance mode in System Center Operations Manager 2007</strong></em></p>
<p>La description détaillée de cela se trouve sur le site de Microsoft : 
<a  href="http://support.microsoft.com/kb/942866" onclick="javascript:pageTracker._trackPageview('/external/support.microsoft.com/kb/942866');" >http://support.microsoft.com/kb/942866</a></p>
<p>En fait, pour mettre un serveur en Maintenance Mode, il faut mettre en réalité trois objets en Maintenance :</p>
<ul>
<li>Computers</li>
<li>Health Service</li>
<li>Health Service Watcher</li>
</ul>
<p>Plutot que de faire cela à la main à chaque fois que vous souhaitez mettre un odirnateur completement en Maintenance Mode, voici deux scripts que j&#8217;ai écris.</p>
<pre><font color="#0000ff">
# ==============================================================================================
#
# Microsoft PowerShell Source File
#
# NAME: StartMaintenanceMode.ps1
#
# AUTHOR: Christopher Keyaert
# EMAIL: christopher.keyaert@ucb-group.com
#
# DATE  : 11/19/2008
# VERSION : 1.0
#
# COMMENT: This script will start the maintenance mode for the specified computer
#
# PARAMETERS: rootMS, computerPrincipalName, minutes, comment, reason
#
#
#
# ==============================================================================================

param($rootMS,$computerPrincipalName,$minutes,$comment,$reason)

Add-PSSnapin "Microsoft.EnterpriseManagement.OperationsManager.Client" -ErrorVariable errSnapin;
Set-Location "OperationsManagerMonitoring::" -ErrorVariable errSnapin;
new-managementGroupConnection -ConnectionString:$rootMS -ErrorVariable errSnapin;
set-location $rootMS -ErrorVariable errSnapin;

$computerClass = get-monitoringclass -name:Microsoft.Windows.Computer
$healthServiceClass = get-monitoringclass -name:Microsoft.SystemCenter.HealthService
$healthServiceWatcherClass = get-monitoringclass -name:Microsoft.SystemCenter.HealthServiceWatcher
$computerCriteria = "PrincipalName='" + $computerPrincipalName + "'"
$computer = get-monitoringobject -monitoringclass:$computerClass -criteria:$computerCriteria
$healthServices = $computer.GetRelatedMonitoringObjects($healthServiceClass)
$healthService = $healthServices[0]
$healthServiceCriteria = "HealthServiceName='" + $computerPrincipalName + "'"
$healthServiceWatcher = get-monitoringobject -monitoringclass:$healthServiceWatcherClass -criteria:$healthServiceCriteria
$startTime = [System.DateTime]::Now
$endTime = $startTime.AddMinutes($minutes)

"Putting " + $computerPrincipalName + " into maintenance mode"
New-MaintenanceWindow -startTime:$startTime -endTime:$endTime -monitoringObject:$computer -comment:$comment -Reason:$reason

"Putting the associated health service into maintenance mode"
New-MaintenanceWindow -startTime:$startTime -endTime:$endTime -monitoringObject:$healthService -comment:$comment -Reason:$reason

"Putting the associated health service watcher into maintenance mode"
New-MaintenanceWindow -startTime:$startTime -endTime:$endTime -monitoringObject:$healthServiceWatcher -comment:$comment -Reason:$reason

</font></pre>
<p><font color="#000000">Le second, pour arrêter le Maintenance Mode</font></p>
<pre><font color="#0000ff">
# ==============================================================================================
#
# Microsoft PowerShell Source File
#
# NAME: StopMaintenanceMode.ps1
#
# AUTHOR: Christopher Keyaert
# EMAIL: christopher.keyaert@ucb-group.com
#
# DATE  : 11/19/2008
# VERSION : 1.0
#
# COMMENT: This script will stop the maintenance mode for the specified computer
#
# PARAMETERS: rootMS, computerPrincipalName
#
#
#
# ==============================================================================================

param($rootMS,$computerPrincipalName)

Add-PSSnapin "Microsoft.EnterpriseManagement.OperationsManager.Client" -ErrorVariable errSnapin;
Set-Location "OperationsManagerMonitoring::" -ErrorVariable errSnapin;
new-managementGroupConnection -ConnectionString:$rootMS -ErrorVariable errSnapin;
set-location $rootMS -ErrorVariable errSnapin;

$computerClass = get-monitoringclass -name:Microsoft.Windows.Computer
$healthServiceClass = get-monitoringclass -name:Microsoft.SystemCenter.HealthService
$healthServiceWatcherClass = get-monitoringclass -name:Microsoft.SystemCenter.HealthServiceWatcher
$computerCriteria = "PrincipalName='" + $computerPrincipalName + "'"
$computer = get-monitoringobject -monitoringclass:$computerClass -criteria:$computerCriteria
$healthServices = $computer.GetRelatedMonitoringObjects($healthServiceClass)
$healthService = $healthServices[0]
$healthServiceCriteria = "HealthServiceName='" + $computerPrincipalName + "'"
$healthServiceWatcher = get-monitoringobject -monitoringclass:$healthServiceWatcherClass -criteria:$healthServiceCriteria

$endTime = [System.DateTime]::Now

"Stopping " + $computerPrincipalName + " maintenance mode"
Set-MaintenanceWindow -endTime:$endTime -monitoringObject:$computer

"Stopping the associated health service maintenance mode"
Set-MaintenanceWindow -endTime:$endTime -monitoringObject:$healthService

"Stopping the associated health service watcher maintenance mode"
Set-MaintenanceWindow -endTime:$endTime -monitoringObject:$healthServiceWatcher

</font></pre>
<p><font color="#000000">Et voici comment appeller ces deux scripts</font></p>
<pre><font color="#0000ff">Start maintenance mode</font><font color="#0000ff">
</font><font color="#0000ff"> C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe C:\MaintenanceMode\StartMaintenanceMode.ps1 –rootMS: ‘localhost’ -computerPrincipalName: 'SERVERNAME' -minutes:30 -comment: 'Maintenance Mode' -reason: 'PlannedOther'</font></pre>
<pre><font color="#0000ff">Stop maintenance mode</font><font color="#0000ff">
</font><font color="#0000ff"> C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe C:\MaintenanceMode\StopMaintenanceMode.ps1 –rootMS: ‘localhost’ -computerPrincipalName: 'SERVERNAME'</font></pre>
<p><font color="#000000">Voilà, si vous avez des questions, ne pas hésiter à les poser dans les commentaires.<br />
</font></p>
]]></content:encoded>
			<wfw:commentRss>http://www.leveilleur.net/index.php/2008/11/23/scom2007-scripts-pour-maintenance-mode/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
