-
- Enthusiast
- Posts: 88
- Liked: 2 times
- Joined: Jul 31, 2013 12:05 pm
- Full Name: Si
- Contact:
SureReplica Custom Script to run chkdsk
Hi, is it possible for a SureReplica custom script to run chkdsk on the VM(s) in the job and only succeed if the chkdsk operation ends with:
"Windows has scanned the file system and found no problems."
Main reason is because just booting them up and ping testing them isn't enough, I've had corruption in my replica VMs recently and some booted fine but reported errors on the other drives due to corruption.
I know there is some built in tests but these are no good for just file servers etc.
Thanks
Simon
"Windows has scanned the file system and found no problems."
Main reason is because just booting them up and ping testing them isn't enough, I've had corruption in my replica VMs recently and some booted fine but reported errors on the other drives due to corruption.
I know there is some built in tests but these are no good for just file servers etc.
Thanks
Simon
-
- Veeam Software
- Posts: 649
- Liked: 171 times
- Joined: Dec 10, 2012 8:44 am
- Full Name: Nikita Efes
- Contact:
Re: SureReplica Custom Script to run chkdsk
You can create simple .ps1 (or any other script language you like) script, that will call chkdsk remotely, parse it's output and return 0 if chkdsk returned that string.
Generally SureReplica and SureBackup can run any command, that can be run in Windows Shell on Backup console and report success only if exit code is 0.
Generally SureReplica and SureBackup can run any command, that can be run in Windows Shell on Backup console and report success only if exit code is 0.
-
- Enthusiast
- Posts: 88
- Liked: 2 times
- Joined: Jul 31, 2013 12:05 pm
- Full Name: Si
- Contact:
Re: SureReplica Custom Script to run chkdsk
Ok great, any chance you give me a starting point, I have no idea how to "call chkdsk remotely and parse it's output" ?!
-
- Veeam Software
- Posts: 649
- Liked: 171 times
- Joined: Dec 10, 2012 8:44 am
- Full Name: Nikita Efes
- Contact:
Re: SureReplica Custom Script to run chkdsk
Here is the sample script to achieve your goal.
Please be aware that you need to set up authentication mode that will fit you security settings.
Please be aware that you need to set up authentication mode that will fit you security settings.
Code: Select all
$result = Invoke-Command -ComputerName <name> -ScriptBlock {chkdsk c:} -Authentication CredSSP -Credential $creds #add keys of chkdsk you need
if ($result -contains "Windows has scanned the file system and found no problems.")
{
return 0 #scan returned that all was good, report success to SureReplica
}
else
{
return 1 #string not found, chkdsk found some errors. you can add here any other actions, for example logging $result or sending e-mail with it in body
}
-
- Enthusiast
- Posts: 88
- Liked: 2 times
- Joined: Jul 31, 2013 12:05 pm
- Full Name: Si
- Contact:
Re: SureReplica Custom Script to run chkdsk
Thanks! 
So do I call that script with %vm_fqdn% for the virtual lab VM and credentials?
Sorry I really don't have much knowledge or experience with this or powershell. Can I have the credentials hard coded with a domain account, eg. -Credential DOMAIN\USERNAME password ?
I guess I also need it to see what drives that are in that VM and scan all of them somehow.

So do I call that script with %vm_fqdn% for the virtual lab VM and credentials?
Sorry I really don't have much knowledge or experience with this or powershell. Can I have the credentials hard coded with a domain account, eg. -Credential DOMAIN\USERNAME password ?
I guess I also need it to see what drives that are in that VM and scan all of them somehow.
-
- Veeam Software
- Posts: 649
- Liked: 171 times
- Joined: Dec 10, 2012 8:44 am
- Full Name: Nikita Efes
- Contact:
Re: SureReplica Custom Script to run chkdsk
I believe, it should be masquerade ip to ensure you are connecting to surereplica vm, not production one.CaptainFred wrote: So do I call that script with %vm_fqdn% for the virtual lab VM and credentials?
You can review types of authentication, allowed in Invoke-Command, at Technet: http://technet.microsoft.com/en-us/libr ... 49719.aspxCaptainFred wrote: Sorry I really don't have much knowledge or experience with this or powershell. Can I have the credentials hard coded with a domain account, eg. -Credential DOMAIN\USERNAME password ?
Some of them requires you to store and pass username and password, others use the account that is started the script. Also most of them require some settings in your domain and/or vm. It is too much different types to describe all of them in forum post.
I'm not so good with chkdisk command, maybe there's some keys that allow you to check all connected disks.CaptainFred wrote: I guess I also need it to see what drives that are in that VM and scan all of them somehow.
-
- Product Manager
- Posts: 20673
- Liked: 2378 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: SureReplica Custom Script to run chkdsk
You can, probably, get list of all connected drives, and, then, perform chkdsk on them. The corresponding commands used below has been appropriated from this article:
Thanks.
Code: Select all
Foreach ($LogicalDisk in (Get-WmiObject Win32_logicaldisk))
{
$LogicalDisk.Chkdsk
}
-
- Enthusiast
- Posts: 88
- Liked: 2 times
- Joined: Jul 31, 2013 12:05 pm
- Full Name: Si
- Contact:
Re: SureReplica Custom Script to run chkdsk
Ok, so do I need to use %vm_ip% then instead?nefes wrote: I believe, it should be masquerade ip to ensure you are connecting to surereplica vm, not production one.
This all seems very complicated. I'm not even sure what to put in the "Name" and "Path" boxes in the Test Scripts option? Do I just point it directly to a ps1 file?
Thanks
-
- Product Manager
- Posts: 20673
- Liked: 2378 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: SureReplica Custom Script to run chkdsk
Correct.Do I just point it directly to a ps1 file?
-
- Enthusiast
- Posts: 88
- Liked: 2 times
- Joined: Jul 31, 2013 12:05 pm
- Full Name: Si
- Contact:
Re: SureReplica Custom Script to run chkdsk
ok, do I need to use %vm_ip% then instead?
-
- Product Manager
- Posts: 20673
- Liked: 2378 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: SureReplica Custom Script to run chkdsk
It seems that you can disregard "argument" section, as the script itself has the part responsible for connecting to the given VM. Thanks.
-
- Veeam Software
- Posts: 1838
- Liked: 661 times
- Joined: Mar 02, 2012 1:40 pm
- Full Name: Timothy Dewin
- Contact:
Re: SureReplica Custom Script to run chkdsk
For storing the password you can use convertfrom-securestring to save the password your requested with get-credential in an encrypted way. Watch out, it can only be decrypted by the user that stored the password in the first place. So your code must run using this user, which I guess will be the backup service user (but haven't got the time to test that)
Then you can retrieve the password like this and create "credentials"
http://technet.microsoft.com/en-us/maga ... 14574.aspx
http://technet.microsoft.com/en-us/libr ... 49814.aspx
http://technet.microsoft.com/en-us/libr ... 49818.aspx
Code: Select all
$passfile = "c:\d\encrypted.pass"
$creds = get-credential
$creds.password | ConvertFrom-SecureString | out-file $passfile
Code: Select all
$passfile = "c:\d\encrypted.pass"
$credlogon = New-Object PSCredential "domain\user",(get-content $passfile | ConvertTo-SecureString)
http://technet.microsoft.com/en-us/libr ... 49814.aspx
http://technet.microsoft.com/en-us/libr ... 49818.aspx
-
- Enthusiast
- Posts: 88
- Liked: 2 times
- Joined: Jul 31, 2013 12:05 pm
- Full Name: Si
- Contact:
Re: SureReplica Custom Script to run chkdsk
Thanks but I don't really care if the password is in plain text in the script because the only people who could see it are people with access to the server which are admins anyway. Or is that not possible because of security in Windows etc?
-
- Veeam Software
- Posts: 1838
- Liked: 661 times
- Joined: Mar 02, 2012 1:40 pm
- Full Name: Timothy Dewin
- Contact:
Re: SureReplica Custom Script to run chkdsk
I didn't test it but it seems, you can use convertto-securestring with the -asplaintext -force parameter. This you can then reuse to create credentials
Code: Select all
$securestring = ConvertTo-SecureString -string "mynotsosecretpass" -asplaintext -force
New-Object PSCredential "domain\user",$securestring
-
- Enthusiast
- Posts: 88
- Liked: 2 times
- Joined: Jul 31, 2013 12:05 pm
- Full Name: Si
- Contact:
Re: SureReplica Custom Script to run chkdsk
When SureBackup runs a custom script on a VM does it not run it under any credentials then? Not even the service accounts that it uses for backup/replication/VM indexing tasks?
-
- Novice
- Posts: 3
- Liked: never
- Joined: Jun 17, 2015 6:47 am
- Contact:
[MERGED] : CHKDSK.exe script for SureBackup
Hello,
I want to use chkdsk.exe in order to check our backups with SureBackup. I am new in this topic. Is there any script template?
Thank You,
Stephan
I want to use chkdsk.exe in order to check our backups with SureBackup. I am new in this topic. Is there any script template?
Thank You,
Stephan
-
- Product Manager
- Posts: 20673
- Liked: 2378 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: SureReplica Custom Script to run chkdsk
Hi, Stephan,
Check the examples provided above and see whether they answer your requirements.
Thanks.
Check the examples provided above and see whether they answer your requirements.
Thanks.
-
- Enthusiast
- Posts: 66
- Liked: 5 times
- Joined: Jul 10, 2012 8:15 am
- Full Name: Luke
- Contact:
Re: SureReplica Custom Script to run chkdsk
Hey Guys
Sorry to bring up this thread again however i think it is relevant due to all the CBT errors that have been coming up in vmware. I have started working on a powershell / WMI script to test logical drives for corruption however I'm finding WMI often craps out before it finishes due to some sort of wmi limitation.
Just wondering how you guys are managing to run a chkdsk during a surebackup job
Sorry to bring up this thread again however i think it is relevant due to all the CBT errors that have been coming up in vmware. I have started working on a powershell / WMI script to test logical drives for corruption however I'm finding WMI often craps out before it finishes due to some sort of wmi limitation.
Just wondering how you guys are managing to run a chkdsk during a surebackup job
Who is online
Users browsing this forum: Bing [Bot] and 17 guests