Using a variable for $db.SetOwner
does know how can use variable this?
$owner = "someowner" $srv = new-object microsoft.sqlserver.management.smo.server($destinationinstance) $db = new-object microsoft.sqlserver.management.smo.database $db = $srv.databases.item($sourcedbname) $db.setowner($owner, $true)
gives me errors when try above.
if use $db.setowner('sa', $true) works need hold variable.
system.argumentexception: login 'microsoft.powershell.commands.internal.format.formatstartdata microsoft.powershell.commands.internal.format.groupstartdata microsoft.powershell.commands.internal.format.formatentrydata microsoft.powershell.commands.internal.format.groupenddata microsoft.powershell.commands.internal.format.formatenddata'
this error message indicates $owner variable contains format object not simple string. format objects procuced after pipelining data through format-table cmdlet. assigning such objects string variable produces default behaviour, ie, type of object components displayed. avoid using format-table , use out-string instead , example.
for further details : http://social.technet.microsoft.com/forums/en-us/winserverpowershell/thread/fb956c33-075e-4b17-9a30-5e7ed38ef2aa
wizend
Windows Server > Windows PowerShell
Comments
Post a Comment