Creating a credential

This recipe goes through the code needed for creating a SQL Server credential.

Getting ready

In this recipe, we will create a credential for a domain account that has access to certain files and folders in our system, QUERYWORKS\filemanager. Here's the equivalent T-SQL of what we are trying to accomplish:

CREATE CREDENTIAL [filemanagercred]
WITH IDENTITY = N'QUERYWORKS\filemanager',
SECRET = N'YourSuperStrongPassword'

You can substitute this with another known Windows account you have in your environment.

How to do it...

These are the steps to create a credential:

  1. Open PowerShell ISE as an administrator.
  2. Import the SQLPS module and create a new SMO Server Object:
    #import SQL Server module Import-Module SQLPS -DisableNameChecking #replace ...

Get SQL Server 2014 with PowerShell v5 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.