I look at the list of objects Microsoft.SqlServer.Management.Smo.Serverand add them to the hash table as follows:
$instances = Get-Content -Path .\Instances.txt
$scripts = @{}
foreach ($i in $instances)
{
$instance = New-Object Microsoft.SqlServer.Management.Smo.Server $i
foreach($login in $instance.Logins)
{
$scripts.Add($instance.Name, $login.Script())
}
}
So far so good. Now I want to add a row to the end of the hash table value. Therefore, for the instance of $, I want to add a row to the hash table value for this instance of $. How should I do it? I started with this, but I'm not sure I'm on the right track:
foreach ($db in $instance.Databases)
{
foreach ($luser in $db.Users)
{
if(!$luser.IsSystemObject)
{
$scripts.Set_Item ($instance, <what do I add in here?>)
}
}
}
Greetings
source
share