August 15, 2017 at 9:35 am
I am new to Powershell and I am currently trying to figure out why the below is not returning the server\instance as part of the script. I am guessing its because of the named instance and the '\'
It is returning the other info, just not the server\instance
---------------------------
$instances = @('Server1\Instance1','Server1\instance2')
$instances | ForEach-Object {get-childitem "SQLSERVER:\SQL\$_\databases" -Force} |
Sort-Object size -descending |
Select-Object @{n='Server';e={$_parent.Name}},name,lastbackupdate,size
--------------------------------------
August 15, 2017 at 11:37 am
I believe it's because you're trying to apply a method to a property. This should work
$instances = @('Server1\Instance1','Server1\Instance2')
$instances |
ForEach-Object {Get-ChildItem "SQLSERVER:\SQL\$_\databases" -Force} |
Sort-Object Size -Descending |
Select-Object @{n='Server';e={$_.parent}}, name, lastbackupdate, size
August 16, 2017 at 4:27 am
much appreciated - that works!
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy