Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8423167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:39:10+00:00 2026-06-10T03:39:10+00:00

Hi i am trying to write a powershell script to create a backup of

  • 0

Hi i am trying to write a powershell script to create a backup of mdf file(sqlserver database file) on windows7 ultimate machine

but when i run my script it show me error:

New-Object : Cannot find type [Microsoft.SqlServer.Management.Smo.Backup]: make sure the assembly
is loaded.
At C:\Users\abc\tmp.ps1:5 char:23
+ $dbBackup = new-object <<<<  ("Microsoft.SqlServer.Management.Smo.Backup")
    + CategoryInfo          : InvalidType: (:) [New-Object], PSArgumentException
    + FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand

Property 'Database' cannot be found on this object; make sure it exists and is settable.
At C:\Users\abc\tmp.ps1:8 char:11
+ $dbBackup. <<<< Database = "ds"
    + CategoryInfo          : InvalidOperation: (Database:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

You cannot call a method on a null-valued expression.
At C:\Users\abc\tmp.ps1:11 char:28
+ $dbBackup.Devices.AddDevice <<<< ("D:\backups\BLACKSWASTIK.bak", "File")
    + CategoryInfo          : InvalidOperation: (AddDevice:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

Property 'Action' cannot be found on this object; make sure it exists and is settable.
At C:\Users\abc\tmp.ps1:14 char:11
+ $dbBackup. <<<< Action="Database"
    + CategoryInfo          : InvalidOperation: (Action:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

You cannot call a method on a null-valued expression.
At C:\Users\abc\tmp.ps1:17 char:20
+ $dbBackup.SqlBackup <<<< ($s)
    + CategoryInfo          : InvalidOperation: (SqlBackup:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

here is my code:

[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SMO') | out-null
$s = New-Object ('Microsoft.SqlServer.Management.Smo.Server') "localhost\sqlexpress2008"


$dbBackup = new-object ("Microsoft.SqlServer.Management.Smo.Backup")

#Set the Database property to Northwind 
$dbBackup.Database = "bs"

#Add the backup file to the Devices collection and specify File as the backup type 
$dbBackup.Devices.AddDevice("D:\backups\BLACKSWASTIK.bak", "File")

#Specify the Action property to generate a FULL backup 
$dbBackup.Action="Database"

#Call the SqlBackup method to generate the backup 
$dbBackup.SqlBackup($s)

This code is work fine on xp machine but i want to run it on windows7 ultimate machine is there anything needs to be change ? Please suggest….

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T03:39:11+00:00Added an answer on June 10, 2026 at 3:39 am

    @Brandon has the right idea, but not quite up-to-date information. If you review this MSDN page on the sqlps utility you will see that it is deprecated, stating that “This feature will be removed in a future version of Microsoft SQL Server” in the second paragraph. That is indeed the case as of SQL Server 2012, which comes with the sqlps module built-in (as distinct from the sqlps utility). You can, as Brandon suggested make your own sqlps module but you do not need to because there is a version available for download at the end of this article. For the complete twisted, obfuscated, and gruesome tale of “sqlps” vs “sqlps” vs “sqlps” see Practical PowerShell for SQL Server Developers and DBAs, part 1 and part 2, that were just published on Simple-Talk.com. You will also find a link there for my wallchart that puts everything you need to know from both articles onto a single sheet.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a custom powershell script that will create a local user
I'm trying to write a powershell script which will execute sqlcmd.exe to run a
I am trying to write a Powershell script to run a general SQL command
I am trying to write a script in PowerShell to backup our collection of
I'm trying to write a powershell script that uses the git commit-tree command but
I trying to write a PowerShell script (learning at the same time). I have
I'm trying to write a powershell script that updats each of the DiagnosticsConnectionString and
I am trying to write a powershell script that will take in a text
I'm trying to write a PowerShell script that will do the following: Executes a
I am trying to write a PowerShell script to replace the contents of tags

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.