I have just stumbled upon a very promising looking post by Jörgen Nilsson, in it he shows how to have SCCM automatically merge conflicting records using a combination of a vbs script and a status filter rule, check it out!
Auto merging SCCM conflicting records
Most Popular Posts
Sunday, 27 March 2011
Tuesday, 1 March 2011
Powershell script to monitor for idle CPU then put computer to sleep
Good evening, I have been working on a little powershell script and thought I would post it as it might come in handy for others.
Basically my laptop stays on 24/7 (its tucked away in a corner and runs DNS, DHCP,Downloads and that kind of thing). What I want to do is if nothing is downloading on it overnight then I want it to sleep. I use JDownloader to auto download files for me overnight which has the auto extract (unrar.exe) feature built in too. Take a look at the script you will see it looks for unrar.exe and if that isnt running checks the cpu usage of jdownloader (javaw.exe) if it is below a certain value 5 times then the powershell script calls a batch file and the laptop sleeps.
When it hits 7am a scheduled task (to ping localhost) wakes it up again, nice huh? :)
Anyway enough babbling heres the script:
####### SCRIPT START #######
[int]$ProcessorInactive = $null
do {if(($ProcessorInactive) -le 5)
{
Write-host "ProcessorInactive is less than 5"
do {if(($ProcessActive = Get-Process unrar -ErrorAction SilentlyContinue) -ne $null)
{
Write-host "unrar is active"
$ProcessAlive = "SomeValue"
Start-Sleep -Seconds 900
}
else
{
Write-host "unrar isnt active"
$Process = Get-Counter -Counter "\Process(javaw)\% Processor Time"
$Sample = $process.Countersamples[0]
$CpuTime = $Sample.CookedValue
$CpuTime = ($CpuTime/2)
do {if(($CpuTime) -gt 3)
{
Write-host "CpuTime is higher than 3"
Start-Sleep -Seconds 10
$Process = Get-Counter -Counter "\Process(javaw)\% Processor Time"
$Sample = $process.Countersamples[0]
$CpuTime = $Sample.CookedValue
$CpuTime = ($CpuTime/2)
}
else
{
Write-host "CpuTime is less than 3 now"
}
}
while ($CpuTime -gt 3)
#clear this variable else we will loop forever
$ProcessAlive = $null
$ProcessorInactive++
Start-Sleep -Seconds 30
}}
while (($ProcessAlive) -ne $null)
}
}
while ($ProcessorInactive -le 5)
echo "********VERY END OF SCRIPT NOW DO WHAT YOU WANT HERE*******"
cmd /c """H:\powershell\Sleep.bat"""
####### SCRIPT END #######
And if anyone wants to know the contents of "sleep.bat" are:
rundll32.exe powrprof.dll,SetSuspendState
Note: Aside from the obvious you may have to change this part:
$CpuTime = ($CpuTime/2)
to the number of cores you have (my laptop has 2) as the cpu usage is a total of all cores
Thanks for reading and hope it helps someone! :)
EDIT: I have since changed the cputime percentage for javaw.exe to 1 to see if this improves the script. I think that with it set to 3 the script is sometimes catching the usage below 3% 5 times and sleeping even though there are downloads left so altering this value should help. The 2 parts you need to change are line 21 & line 36
Basically my laptop stays on 24/7 (its tucked away in a corner and runs DNS, DHCP,Downloads and that kind of thing). What I want to do is if nothing is downloading on it overnight then I want it to sleep. I use JDownloader to auto download files for me overnight which has the auto extract (unrar.exe) feature built in too. Take a look at the script you will see it looks for unrar.exe and if that isnt running checks the cpu usage of jdownloader (javaw.exe) if it is below a certain value 5 times then the powershell script calls a batch file and the laptop sleeps.
When it hits 7am a scheduled task (to ping localhost) wakes it up again, nice huh? :)
Anyway enough babbling heres the script:
####### SCRIPT START #######
[int]$ProcessorInactive = $null
do {if(($ProcessorInactive) -le 5)
{
Write-host "ProcessorInactive is less than 5"
do {if(($ProcessActive = Get-Process unrar -ErrorAction SilentlyContinue) -ne $null)
{
Write-host "unrar is active"
$ProcessAlive = "SomeValue"
Start-Sleep -Seconds 900
}
else
{
Write-host "unrar isnt active"
$Process = Get-Counter -Counter "\Process(javaw)\% Processor Time"
$Sample = $process.Countersamples[0]
$CpuTime = $Sample.CookedValue
$CpuTime = ($CpuTime/2)
do {if(($CpuTime) -gt 3)
{
Write-host "CpuTime is higher than 3"
Start-Sleep -Seconds 10
$Process = Get-Counter -Counter "\Process(javaw)\% Processor Time"
$Sample = $process.Countersamples[0]
$CpuTime = $Sample.CookedValue
$CpuTime = ($CpuTime/2)
}
else
{
Write-host "CpuTime is less than 3 now"
}
}
while ($CpuTime -gt 3)
#clear this variable else we will loop forever
$ProcessAlive = $null
$ProcessorInactive++
Start-Sleep -Seconds 30
}}
while (($ProcessAlive) -ne $null)
}
}
while ($ProcessorInactive -le 5)
echo "********VERY END OF SCRIPT NOW DO WHAT YOU WANT HERE*******"
cmd /c """H:\powershell\Sleep.bat"""
####### SCRIPT END #######
And if anyone wants to know the contents of "sleep.bat" are:
rundll32.exe powrprof.dll,SetSuspendState
Note: Aside from the obvious you may have to change this part:
$CpuTime = ($CpuTime/2)
to the number of cores you have (my laptop has 2) as the cpu usage is a total of all cores
Thanks for reading and hope it helps someone! :)
EDIT: I have since changed the cputime percentage for javaw.exe to 1 to see if this improves the script. I think that with it set to 3 the script is sometimes catching the usage below 3% 5 times and sleeping even though there are downloads left so altering this value should help. The 2 parts you need to change are line 21 & line 36
Friday, 11 February 2011
16TB limit on NTFS Volume!
I have been working on upgrading my server (Areca-1230) with 12x2TB drives and hit a volume/partition limit at 16TB.
I stuck the 12x2TB drives in a RAID5 (could have used RAID 6 but its sloooooow!) and discovered I couldnt create a partition in windows server 2008 R2 larger than 16TB without using the format /A command. This basically allows you to specify your own cluster size and as you can see from the following link, certain cluster sizes limit your ability to create certain size volumes (see David Shens reply):
Clicky!--->Cluster Sizes<----Clicky!
The moral of this blog post is, before you create a monster volume double check your cluster size otherwise (as I found out) you wont get very far!
Of course you could just have a few smaller volumes running from one giant raidset but wheres the fun in that?
Thanks for reading :)
I stuck the 12x2TB drives in a RAID5 (could have used RAID 6 but its sloooooow!) and discovered I couldnt create a partition in windows server 2008 R2 larger than 16TB without using the format /A command. This basically allows you to specify your own cluster size and as you can see from the following link, certain cluster sizes limit your ability to create certain size volumes (see David Shens reply):
Clicky!--->Cluster Sizes<----Clicky!
The moral of this blog post is, before you create a monster volume double check your cluster size otherwise (as I found out) you wont get very far!
Of course you could just have a few smaller volumes running from one giant raidset but wheres the fun in that?
Thanks for reading :)
Monday, 3 January 2011
THE way to fix "Attention! Your web page request has been cancelled"
wow this one is persistent! and if you have seen it you know what im talking about. No amount of scanning with mbam, comboxfix any antivirus software can fix this.

However...
boot into recovery console, log on to your windows installation and type "fixmbr" and all of your problems will go away,
Phew! this one *almost* made me reinstall the computer in question but persistance on my part paid off.
Please leave a comment and say thanks if this helped you :)
However...
boot into recovery console, log on to your windows installation and type "fixmbr" and all of your problems will go away,
Phew! this one *almost* made me reinstall the computer in question but persistance on my part paid off.
Please leave a comment and say thanks if this helped you :)
Saturday, 25 December 2010
Create your own wireless reciever for an xbox 360 pad for use with your PC
I wanted to use a wireless 360 pad to play N64 on my HDTV at 1080p with texture filters etc whacked up to max (N64 is my fav console ever) so I did a bit of googling.
Almost instantly I found this video:
Its good but doesnt show you what diode is used to limit the voltage. So I built a circuit to limit the voltage using an LM317, a 220ohm & a 360ohm resistor to produce an output of 3.3V (as 3.3V is what the front panel needs to power it)
I used this site to calculate the resistors I needed
http://www.reuk.co.uk/LM317-Voltage-Calculator.htm
So I cut the end off a USB cable, soldered the TX and RX wires in place and then built a circuit on a breadboard to take in the +5V and GND from USB and output the GND and 3.3V. See below for the schematic and picture (my first schematic so be nice! :p)


(The resistors shown above are actually different values so dont take these as the correct ones! but you get the idea)
Anyway this works fine after you install the driver from microsoft, I had to manually point the device at the XUSB21.inf file for it to pick it up.
The problem with this receiver however is that you cannot sync it with a pad, you have to put it back into a 360, sync it and then take it out. So my next challenge and a very big one and it is to create a sync button.
So far someone has pointed me at this thread:
http://forums.xbox-experts.com/viewtopic.php?f=13&t=138
Its all very advanced stuff for me at the moment but with determination and a goal in mind anything is possible
Thanks for reading! :)
Almost instantly I found this video:
Its good but doesnt show you what diode is used to limit the voltage. So I built a circuit to limit the voltage using an LM317, a 220ohm & a 360ohm resistor to produce an output of 3.3V (as 3.3V is what the front panel needs to power it)
I used this site to calculate the resistors I needed
http://www.reuk.co.uk/LM317-Voltage-Calculator.htm
So I cut the end off a USB cable, soldered the TX and RX wires in place and then built a circuit on a breadboard to take in the +5V and GND from USB and output the GND and 3.3V. See below for the schematic and picture (my first schematic so be nice! :p)
(The resistors shown above are actually different values so dont take these as the correct ones! but you get the idea)
Anyway this works fine after you install the driver from microsoft, I had to manually point the device at the XUSB21.inf file for it to pick it up.
The problem with this receiver however is that you cannot sync it with a pad, you have to put it back into a 360, sync it and then take it out. So my next challenge and a very big one and it is to create a sync button.
So far someone has pointed me at this thread:
http://forums.xbox-experts.com/viewtopic.php?f=13&t=138
Its all very advanced stuff for me at the moment but with determination and a goal in mind anything is possible
Thanks for reading! :)
Subscribe to:
Posts (Atom)