Jay Thomas
asked on
PS script not working as it should?
Script error. Hi all. I am attempting to set the VSS disk size via PS. When I run the script, and the VM name I'm running the script from, it will make the change to that VM. But, I have other server names in the script on the same domain but it doesn't work. Reports the message in the 'Throw' section. I am running with admin, how can I get the commands to run on remote servers?
$computers = Get-Content -Path C:\temp\servers.txt
$VssWriters | Out-GridView # Displays it in GridView
$VssWriters | Export-CSV ".\myReport.csv" -NoTypeInformation # Exports it to CSV
If ((Get-Content -Path C:\temp\servers.txt) -notcontains $Computers) {
Throw "The Virtual Machine named specified does not appear in the to do list"
}
$VssWriters = vssadmin resize shadowstorage /for=c: /on=c: /maxsize=15GB
$computers = Get-Content -Path C:\temp\servers.txt
$VssWriters | Out-GridView # Displays it in GridView
$VssWriters | Export-CSV ".\myReport.csv" -NoTypeInformation # Exports it to CSV
If ((Get-Content -Path C:\temp\servers.txt) -notcontains $Computers) {
Throw "The Virtual Machine named specified does not appear in the to do list"
}
$VssWriters = vssadmin resize shadowstorage /for=c: /on=c: /maxsize=15GB
Please post a concise and complete example. E.g. $VssWriters is undefined in the first call.
ASKER
Yeah you see that's when I get lost. Not even sure what you mean to be honest.
Well, you may start by posting your script and a sample servers file..
ASKER
So at the moment I use this:
Invoke-Command -ComputerName servername -ScriptBlock { vssadmin resize shadowStorage /for=c: /on=c: /maxsize=12gb } -Credential domain\administrator
This works, I was looking for a way to run this but reference a text file with a bunch of server names rather than having to keep changing the servername in this one-liner.
Invoke-Command -ComputerName servername -ScriptBlock { vssadmin resize shadowStorage /for=c: /on=c: /maxsize=12gb } -Credential domain\administrator
This works, I was looking for a way to run this but reference a text file with a bunch of server names rather than having to keep changing the servername in this one-liner.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry for the late feedback