December 2, 2014 at 7:48 am
I have a server that seems to be missing some properties when accessing via SMO in powershell, specifically the default data and log file locations. These can be viewed through ssms and tsql. Has anyone encountered this before?
December 2, 2014 at 8:01 am
thos locations are stored in the registry, and not in any table, or as a property of a server, as far as i know.
...how are you getting them via powershell?
i get them via a TSQL like this:
EXECUTE [master].dbo.xp_instance_regread N'HKEY_LOCAL_MACHINE',
N'SOFTWARE\Microsoft\MSSQLServer\MSSQLServer',
N'BackupDirectory';
EXECUTE [master].dbo.xp_instance_regread N'HKEY_LOCAL_MACHINE',
N'SOFTWARE\Microsoft\MSSQLServer\MSSQLServer',
N'DefaultData';
EXECUTE [master].dbo.xp_instance_regread N'HKEY_LOCAL_MACHINE',
N'SOFTWARE\Microsoft\MSSQLServer\MSSQLServer',
N'DefaultLog';
Lowell
December 2, 2014 at 8:07 am
Lowell I can grab them that way and might if need be, but ideally in powershell. Its pretty straight forward in powershell
$Instance = New-Object('Microsoft.SqlServer.Management.Smo.Server') $InstanceName
$Instance.DefaultFile
$Instance.DefaultLog
These are blank for a specific instance,but populated for the majority of other instances.
December 2, 2014 at 8:25 am
It looks like it might be a registry issue. There don't appear to be DefaultFile and DefaultLog entries in the standard location. Thanks for pointing me down the right path.
November 23, 2015 at 8:54 am
You might want to try additional properties, because maybe the user does not have rights to VIEW SERVER STATE/DEFINITION .
Or maybe the 2 properties are not being initialized because of the location of the user database files.
Try the following alternatives:
[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SMO') | out-null
$server = new-object ('Microsoft.SqlServer.Management.Smo.Server') 'localhost'
$setting1 = $server.Settings.DefaultFile
$setting2 = $server.Settings.DefaultLog
$setting3 = $server.Information.MasterDBPath
$setting4 = $server.Information.MasterDBLogPath
$setting5 = $server.InstallDataDirectory
September 18, 2019 at 9:56 am
This reply has been reported for inappropriate content.
SMO means [Social Media Optimization] or anything else???
Tandoor Manufacturer in Mumbai
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply