이 항목에서는 사용자가 데이터 저장소에 있는 항목의 내용을 조작할 수 있도록 하는 Windows PowerShell 공급자를 만드는 방법에 대해 설명합니다. 따라서 항목의 콘텐츠를 조작할 수 있는 공급자를 Windows PowerShell 콘텐츠 공급자라고 합니다.
비고
Windows Vista용 Microsoft Windows 소프트웨어 개발 키트 및 .NET Framework 3.0 런타임 구성 요소를 사용하여 이 공급자에 대한 C# 소스 파일(AccessDBSampleProvider06.cs)을 다운로드할 수 있습니다. 다운로드 지침은 Windows PowerShell을 설치하고 Windows PowerShell SDK다운로드하는 방법을 참조하세요. 다운로드한 원본 파일은 <PowerShell 샘플> 디렉터리에서 사용할 수 있습니다. 다른 Windows PowerShell 공급자 구현에 대한 자세한 내용은 windows PowerShell 공급자 디자인하는참조하세요.
Windows PowerShell 콘텐츠 공급자 클래스 정의
Windows PowerShell 콘텐츠 공급자는 System.Management.Automation.Provider.IContentCmdletProvider 인터페이스를 지원하는 .NET 클래스를 만들어야 합니다. 다음은 이 섹션에서 설명하는 항목 공급자에 대한 클래스 정의입니다.
[CmdletProvider("AccessDB", ProviderCapabilities.None)]
public class AccessDBProvider : NavigationCmdletProvider, IContentCmdletProvider
이 클래스 정의에서 System.Management.Automation.Provider.CmdletProviderAttribute 특성에는 두 개의 매개 변수가 포함됩니다. 첫 번째 매개 변수는 Windows PowerShell에서 사용하는 공급자에 대한 사용자 친화적인 이름을 지정합니다. 두 번째 매개 변수는 명령 처리 중에 공급자가 Windows PowerShell 런타임에 노출하는 Windows PowerShell 특정 기능을 지정합니다. 이 공급자의 경우 추가된 Windows PowerShell 특정 기능이 없습니다.
기본 클래스의 기능 정의
Windows PowerShell 공급자 디자인에 설명된 대로 System.Management.Automation.Provider.NavigationCmdletProvider 클래스는 다른 공급자 기능을 제공하는 여러 다른 클래스에서 파생됩니다. 따라서 Windows PowerShell 콘텐츠 공급자는 일반적으로 해당 클래스에서 제공하는 모든 기능을 정의합니다.
세션별 초기화 정보를 추가하고 공급자가 사용하는 리소스를 해제하는 기능을 구현하는 방법에 대한 자세한 내용은 기본 Windows PowerShell 공급자만들기를 참조하세요. 그러나 여기에 설명된 공급자를 포함한 대부분의 공급자는 Windows PowerShell에서 제공하는 이 기능의 기본 구현을 사용할 수 있습니다.
데이터 저장소에 액세스하려면 공급자가 System.Management.Automation.Provider.DriveCmdletProvider 기본 클래스의 메서드를 구현해야 합니다. 이러한 메서드를 구현하는 방법에 대한 자세한 내용은 Windows PowerShell 드라이브 공급자만들기를 참조하세요.
데이터 저장소의 항목(예: 항목 가져오기, 설정 및 지우기)을 조작하려면 공급자가 System.Management.Automation.Provider.ItemCmdletProvider 기본 클래스에서 제공하는 메서드를 구현해야 합니다. 이러한 메서드를 구현하는 방법에 대한 자세한 내용은 Windows PowerShell 항목 공급자만들기를 참조하세요.
다중 계층 데이터 저장소에서 작업하려면 공급자는 System.Management.Automation.Provider.ContainerCmdletProvider 기본 클래스에서 제공하는 메서드를 구현해야 합니다. 이러한 메서드를 구현하는 방법에 대한 자세한 내용은 Windows PowerShell 컨테이너 공급자만들기를 참조하세요.
재귀 명령, 중첩된 컨테이너 및 상대 경로를 지원하려면 공급자가 기본 클래스를 System.Management.Automation.Provider.NavigationCmdletProvider를 구현해야 합니다. 또한 이 Windows PowerShell 콘텐츠 공급자는 System.Management.Automation.Provider.IContentCmdletProvider 인터페이스를 System.Management.Automation.Provider.NavigationCmdletProvider 기본 클래스에 연결할 수 있으므로 해당 클래스에서 제공하는 메서드를 구현해야 합니다. 자세한 내용은 이러한 메서드 구현을 참조하세요. 탐색 Windows PowerShell 공급자구현을 참조하세요.
콘텐츠 판독기 구현
항목에서 콘텐츠를 읽으려면 공급자가 System.Management.Automation.Provider.IContentReader파생되는 콘텐츠 판독기 클래스를 구현해야 합니다. 이 공급자의 콘텐츠 판독기를 사용하면 데이터 테이블의 행 내용에 액세스할 수 있습니다. 콘텐츠 판독기 클래스는 표시된 행에서 데이터를 검색하고 해당 데이터를 나타내는 목록, 콘텐츠 판독기를 이동하는 Seek 메서드, 콘텐츠 판독기를 닫는 Close 메서드 및 Dispose 메서드를 반환하는 Read 메서드를 정의합니다.
public class AccessDBContentReader : IContentReader
{
// A provider instance is required so as to get "content"
private AccessDBProvider provider;
private string path;
private long currentOffset;
internal AccessDBContentReader(string path, AccessDBProvider provider)
{
this.path = path;
this.provider = provider;
}
/// <summary>
/// Read the specified number of rows from the source.
/// </summary>
/// <param name="readCount">The number of items to
/// return.</param>
/// <returns>An array of elements read.</returns>
public IList Read(long readCount)
{
// Read the number of rows specified by readCount and increment
// offset
string tableName;
int rowNumber;
PathType type = provider.GetNamesFromPath(path, out tableName, out rowNumber);
Collection<DatabaseRowInfo> rows =
provider.GetRows(tableName);
Collection<DataRow> results = new Collection<DataRow>();
if (currentOffset < 0 || currentOffset >= rows.Count)
{
return null;
}
int rowsRead = 0;
while (rowsRead < readCount && currentOffset < rows.Count)
{
results.Add(rows[(int)currentOffset].Data);
rowsRead++;
currentOffset++;
}
return results;
} // Read
/// <summary>
/// Moves the content reader specified number of rows from the
/// origin
/// </summary>
/// <param name="offset">Number of rows to offset</param>
/// <param name="origin">Starting row from which to offset</param>
public void Seek(long offset, System.IO.SeekOrigin origin)
{
// get the number of rows in the table which will help in
// calculating current position
string tableName;
int rowNumber;
PathType type = provider.GetNamesFromPath(path, out tableName, out rowNumber);
if (type == PathType.Invalid)
{
throw new ArgumentException("Path specified must represent a table or a row :" + path);
}
if (type == PathType.Table)
{
Collection<DatabaseRowInfo> rows = provider.GetRows(tableName);
int numRows = rows.Count;
if (offset > rows.Count)
{
throw new
ArgumentException(
"Offset cannot be greater than the number of rows available"
);
}
if (origin == System.IO.SeekOrigin.Begin)
{
// starting from Beginning with an index 0, the current offset
// has to be advanced to offset - 1
currentOffset = offset - 1;
}
else if (origin == System.IO.SeekOrigin.End)
{
// starting from the end which is numRows - 1, the current
// offset is so much less than numRows - 1
currentOffset = numRows - 1 - offset;
}
else
{
// calculate from the previous value of current offset
// advancing forward always
currentOffset += offset;
}
} // if (type...
else
{
// for row, the offset will always be set to 0
currentOffset = 0;
}
} // Seek
/// <summary>
/// Closes the content reader, so all members are reset
/// </summary>
public void Close()
{
Dispose();
} // Close
/// <summary>
/// Dispose any resources being used
/// </summary>
public void Dispose()
{
Seek(0, System.IO.SeekOrigin.Begin);
GC.SuppressFinalize(this);
} // Dispose
} // AccessDBContentReader
콘텐츠 작성기 구현
항목에 콘텐츠를 쓰려면 공급자가 system.Management.Automation.Provider.IContentWriter 파생된 콘텐츠 기록기 클래스를 구현해야 합니다. 콘텐츠 작성기 클래스는 지정된 행 콘텐츠를 작성하는 Write 메서드, 콘텐츠 작성기를 이동하는 Seek 메서드, 콘텐츠 작성기를 닫는 Close 메서드 및 Dispose 메서드를 정의합니다.
public class AccessDBContentWriter : IContentWriter
{
// A provider instance is required so as to get "content"
private AccessDBProvider provider;
private string path;
private long currentOffset;
internal AccessDBContentWriter(string path, AccessDBProvider provider)
{
this.path = path;
this.provider = provider;
}
/// <summary>
/// Write the specified row contents in the source
/// </summary>
/// <param name="content"> The contents to be written to the source.
/// </param>
/// <returns>An array of elements which were successfully written to
/// the source</returns>
///
public IList Write(IList content)
{
if (content == null)
{
return null;
}
// Get the total number of rows currently available it will
// determine how much to overwrite and how much to append at
// the end
string tableName;
int rowNumber;
PathType type = provider.GetNamesFromPath(path, out tableName, out rowNumber);
if (type == PathType.Table)
{
OdbcDataAdapter da = provider.GetAdapterForTable(tableName);
if (da == null)
{
return null;
}
DataSet ds = provider.GetDataSetForTable(da, tableName);
DataTable table = provider.GetDataTable(ds, tableName);
string[] colValues = (content[0] as string).Split(',');
// set the specified row
DataRow row = table.NewRow();
for (int i = 0; i < colValues.Length; i++)
{
if (!String.IsNullOrEmpty(colValues[i]))
{
row[i] = colValues[i];
}
}
//table.Rows.InsertAt(row, rowNumber);
// Update the table
table.Rows.Add(row);
da.Update(ds, tableName);
}
else
{
throw new InvalidOperationException("Operation not supported. Content can be added only for tables");
}
return null;
} // Write
/// <summary>
/// Moves the content reader specified number of rows from the
/// origin
/// </summary>
/// <param name="offset">Number of rows to offset</param>
/// <param name="origin">Starting row from which to offset</param>
public void Seek(long offset, System.IO.SeekOrigin origin)
{
// get the number of rows in the table which will help in
// calculating current position
string tableName;
int rowNumber;
PathType type = provider.GetNamesFromPath(path, out tableName, out rowNumber);
if (type == PathType.Invalid)
{
throw new ArgumentException("Path specified should represent either a table or a row : " + path);
}
Collection<DatabaseRowInfo> rows =
provider.GetRows(tableName);
int numRows = rows.Count;
if (offset > rows.Count)
{
throw new
ArgumentException(
"Offset cannot be greater than the number of rows available"
);
}
if (origin == System.IO.SeekOrigin.Begin)
{
// starting from Beginning with an index 0, the current offset
// has to be advanced to offset - 1
currentOffset = offset - 1;
}
else if (origin == System.IO.SeekOrigin.End)
{
// starting from the end which is numRows - 1, the current
// offset is so much less than numRows - 1
currentOffset = numRows - 1 - offset;
}
else
{
// calculate from the previous value of current offset
// advancing forward always
currentOffset += offset;
}
} // Seek
/// <summary>
/// Closes the content reader, so all members are reset
/// </summary>
public void Close()
{
Dispose();
} // Close
/// <summary>
/// Dispose any resources being used
/// </summary>
public void Dispose()
{
Seek(0, System.IO.SeekOrigin.Begin);
GC.SuppressFinalize(this);
} // Dispose
} // AccessDBContentWriter
콘텐츠 판독기 검색
항목에서 콘텐츠를 가져오려면 공급자가 Get-Content
cmdlet을 지원하기 위해 System.Management.Automation.Provider.IContentCmdletProvider.GetContentReader* 구현해야 합니다. 이 메서드는 지정된 경로에 있는 항목의 콘텐츠 판독기를 반환합니다. 그런 다음 판독기 개체를 열어 콘텐츠를 읽을 수 있습니다.
다음은 이 공급자에 대한 이 메서드에 대한 System.Management.Automation.Provider.IContentCmdletProvider.GetContentReader* 구현한 것입니다.
public IContentReader GetContentReader(string path)
{
string tableName;
int rowNumber;
PathType type = GetNamesFromPath(path, out tableName, out rowNumber);
if (type == PathType.Invalid)
{
ThrowTerminatingInvalidPathException(path);
}
else if (type == PathType.Row)
{
throw new InvalidOperationException("contents can be obtained only for tables");
}
return new AccessDBContentReader(path, this);
} // GetContentReader
public IContentReader GetContentReader(string path)
{
string tableName;
int rowNumber;
PathType type = GetNamesFromPath(path, out tableName, out rowNumber);
if (type == PathType.Invalid)
{
ThrowTerminatingInvalidPathException(path);
}
else if (type == PathType.Row)
{
throw new InvalidOperationException("contents can be obtained only for tables");
}
return new AccessDBContentReader(path, this);
} // GetContentReader
GetContentReader 구현에 대해 기억해야 할 사항
다음 조건은 System.Management.Automation.Provider.IContentCmdletProvider.GetContentReader*구현에 적용될 수 있습니다.
공급자 클래스를 정의할 때 Windows PowerShell 콘텐츠 공급자는 System.Management.Automation.Provider.ProviderCapabilities 열거형에서 ExpandWildcards, Filter, Include 또는 Exclude의 공급자 기능을 선언할 수 있습니다. 이러한 경우 System.Management.Automation.Provider.IContentCmdletProvider.GetContentReader* 메서드의 구현은 메서드에 전달된 경로가 지정된 기능의 요구 사항을 충족하는지 확인해야 합니다. 이렇게 하려면 메서드가 적절한 속성(예: System.Management.Automation.Provider.CmdletProvider.Exclude* 및 System.Management.Automation.Provider.CmdletProvider.Include* 속성에 액세스해야 합니다.
기본적으로 이 메서드의 재정의는 System.Management.Automation.Provider.CmdletProvider.Force* 속성이
true
설정되지 않는 한 사용자로부터 숨겨진 개체에 대한 판독기를 검색해서는 안 됩니다. 경로가 사용자로부터 숨겨진 항목을 나타내고 System.Management.Automation.Provider.CmdletProvider.Force*false
설정되면 오류를 기록해야 합니다.
Get-Content Cmdlet에 동적 매개 변수 연결
Get-Content
cmdlet에는 런타임에 동적으로 지정된 추가 매개 변수가 필요할 수 있습니다. 이러한 동적 매개 변수를 제공하려면 Windows PowerShell 콘텐츠 공급자가 system.Management.Automation.Provider.IContentCmdletProvider.GetContentReaderdynamicparameters* 메서드를 구현해야 합니다. 이 메서드는 표시된 경로에서 항목에 대한 동적 매개 변수를 검색하고 cmdlet 클래스 또는 System.Management.Automation.RuntimeDefinedParameterDictionary 개체와 유사한 구문 분석 특성이 있는 속성과 필드가 있는 개체를 반환합니다. Windows PowerShell 런타임은 반환된 개체를 사용하여 cmdlet에 매개 변수를 추가합니다.
이 Windows PowerShell 컨테이너 공급자는 이 메서드를 구현하지 않습니다. 그러나 다음 코드는 이 메서드의 기본 구현입니다.
public object GetContentReaderDynamicParameters(string path)
{
return null;
}
public object GetContentReaderDynamicParameters(string path)
{
return null;
}
콘텐츠 기록기 검색
항목에 콘텐츠를 쓰려면 공급자가 system.Management.Automation.Provider.IContentCmdletProvider.GetContentWriter* 구현하여 Set-Content
및 Add-Content
cmdlet을 지원해야 합니다. 이 메서드는 지정된 경로에 있는 항목의 콘텐츠 기록기를 반환합니다.
다음은 이 메서드에 대한 System.Management.Automation.Provider.IContentCmdletProvider.GetContentWriter* 구현한 것입니다.
public IContentWriter GetContentWriter(string path)
{
string tableName;
int rowNumber;
PathType type = GetNamesFromPath(path, out tableName, out rowNumber);
if (type == PathType.Invalid)
{
ThrowTerminatingInvalidPathException(path);
}
else if (type == PathType.Row)
{
throw new InvalidOperationException("contents can be added only to tables");
}
return new AccessDBContentWriter(path, this);
}
public IContentWriter GetContentWriter(string path)
{
string tableName;
int rowNumber;
PathType type = GetNamesFromPath(path, out tableName, out rowNumber);
if (type == PathType.Invalid)
{
ThrowTerminatingInvalidPathException(path);
}
else if (type == PathType.Row)
{
throw new InvalidOperationException("contents can be added only to tables");
}
return new AccessDBContentWriter(path, this);
}
GetContentWriter 구현에 대해 기억해야 할 사항
다음 조건은 System.Management.Automation.Provider.IContentCmdletProvider.GetContentWriter*구현에 적용될 수 있습니다.
공급자 클래스를 정의할 때 Windows PowerShell 콘텐츠 공급자는 System.Management.Automation.Provider.ProviderCapabilities 열거형에서 ExpandWildcards, Filter, Include 또는 Exclude의 공급자 기능을 선언할 수 있습니다. 이러한 경우 System.Management.Automation.Provider.IContentCmdletProvider.GetContentWriter* 메서드의 구현은 메서드에 전달된 경로가 지정된 기능의 요구 사항을 충족하는지 확인해야 합니다. 이렇게 하려면 메서드가 적절한 속성(예: System.Management.Automation.Provider.CmdletProvider.Exclude* 및 System.Management.Automation.Provider.CmdletProvider.Include* 속성에 액세스해야 합니다.
기본적으로 이 메서드의 재정의는 System.Management.Automation.Provider.CmdletProvider.Force* 속성이
true
설정되지 않는 한 사용자로부터 숨겨진 개체에 대한 기록기를 검색해서는 안 됩니다. 경로가 사용자로부터 숨겨진 항목을 나타내고 System.Management.Automation.Provider.CmdletProvider.Force*false
설정되면 오류를 기록해야 합니다.
Add-Content 및 Set-Content Cmdlet에 동적 매개 변수 연결
Add-Content
및 Set-Content
cmdlet에는 런타임을 추가하는 추가 동적 매개 변수가 필요할 수 있습니다. 이러한 동적 매개 변수를 제공하려면 Windows PowerShell 콘텐츠 공급자가 system.Management.Automation.Provider.IContentCmdletProvider.GetContentWriterDynamicParameters* 메서드를 구현하여 이러한 매개 변수를 처리해야 합니다. 이 메서드는 표시된 경로에서 항목에 대한 동적 매개 변수를 검색하고 cmdlet 클래스 또는 System.Management.Automation.RuntimeDefinedParameterDictionary 개체와 유사한 구문 분석 특성이 있는 속성과 필드가 있는 개체를 반환합니다. Windows PowerShell 런타임은 반환된 개체를 사용하여 cmdlet에 매개 변수를 추가합니다.
이 Windows PowerShell 컨테이너 공급자는 이 메서드를 구현하지 않습니다. 그러나 다음 코드는 이 메서드의 기본 구현입니다.
public object GetContentWriterDynamicParameters(string path)
{
return null;
}
콘텐츠 지우기
콘텐츠 공급자는 Clear-Content
cmdlet을 지원하는 System.Management.Automation.Provider.IContentCmdletProvider.ClearContent* 메서드를 구현합니다. 이 메서드는 지정된 경로에서 항목의 내용을 제거하지만 항목은 그대로 둡니다.
다음은 이 공급자에 대한 System.Management.Automation.Provider.IContentCmdletProvider.ClearContent* 메서드의 구현입니다.
public void ClearContent(string path)
{
string tableName;
int rowNumber;
PathType type = GetNamesFromPath(path, out tableName, out rowNumber);
if (type != PathType.Table)
{
WriteError(new ErrorRecord(
new InvalidOperationException("Operation not supported. Content can be cleared only for table"),
"NotValidRow", ErrorCategory.InvalidArgument,
path));
return;
}
OdbcDataAdapter da = GetAdapterForTable(tableName);
if (da == null)
{
return;
}
DataSet ds = GetDataSetForTable(da, tableName);
DataTable table = GetDataTable(ds, tableName);
// Clear contents at the specified ___location
for (int i = 0; i < table.Rows.Count; i++)
{
table.Rows[i].Delete();
}
if (ShouldProcess(path, "ClearContent"))
{
da.Update(ds, tableName);
}
} // ClearContent
ClearContent 구현에 대해 기억해야 할 사항
다음 조건은 System.Management.Automation.Provider.IContentCmdletProvider.ClearContent*구현에 적용될 수 있습니다.
공급자 클래스를 정의할 때 Windows PowerShell 콘텐츠 공급자는 System.Management.Automation.Provider.ProviderCapabilities 열거형에서 ExpandWildcards, Filter, Include 또는 Exclude의 공급자 기능을 선언할 수 있습니다. 이러한 경우 System.Management.Automation.Provider.IContentCmdletProvider.ClearContent* 메서드의 구현은 메서드에 전달된 경로가 지정된 기능의 요구 사항을 충족하는지 확인해야 합니다. 이렇게 하려면 메서드가 적절한 속성(예: System.Management.Automation.Provider.CmdletProvider.Exclude* 및 System.Management.Automation.Provider.CmdletProvider.Include* 속성에 액세스해야 합니다.
기본적으로 이 메서드의 재정의는 System.Management.Automation.Provider.CmdletProvider.Force* 속성이
true
설정되지 않는 한 사용자로부터 숨겨진 개체의 내용을 지워서는 안 됩니다. 경로가 사용자로부터 숨겨진 항목을 나타내고 System.Management.Automation.Provider.CmdletProvider.Force*false
설정되면 오류를 기록해야 합니다.System.Management.Automation.Provider.IContentCmdletProvider.ClearContent* 메서드 구현은 System.Management.Automation.Provider.CmdletProvider.ShouldProcess 호출하고 데이터 저장소를 변경하기 전에 반환 값을 확인해야 합니다. 이 메서드는 콘텐츠 지우기와 같이 데이터 저장소를 변경할 때 작업의 실행을 확인하는 데 사용됩니다. System.Management.Automation.Provider.CmdletProvider.ShouldProcess 메서드는 사용자에게 변경할 리소스의 이름을 전송하며, Windows PowerShell 런타임은 표시할 대상을 결정할 때 명령줄 설정 또는 기본 설정 변수를 처리합니다.
system.Management.Automation.Provider.CmdletProvider.ShouldProcess 호출하면
true
반환됩니다. System.Management.Automation.Provider.IContentCmdletProvider.ClearContent* 메서드는 System.Management.Automation.Provider.CmdletProvider.ShouldContinue 메서드를 호출해야 합니다. 이 메서드는 사용자에게 메시지를 보내 피드백을 통해 작업을 계속해야 하는지 확인합니다. System.Management.Automation.Provider.CmdletProvider.ShouldContinue 호출하면 잠재적으로 위험한 시스템 수정을 추가로 확인할 수 있습니다.
Clear-Content Cmdlet에 동적 매개 변수 연결
Clear-Content
cmdlet에는 런타임에 추가되는 추가 동적 매개 변수가 필요할 수 있습니다. 이러한 동적 매개 변수를 제공하려면 Windows PowerShell 콘텐츠 공급자가 system.Management.Automation.Provider.IContentCmdletProvider.ClearContentDynamicParameters* 메서드를 구현하여 이러한 매개 변수를 처리해야 합니다. 이 메서드는 표시된 경로에서 항목에 대한 매개 변수를 검색합니다. 이 메서드는 표시된 경로에서 항목에 대한 동적 매개 변수를 검색하고 cmdlet 클래스 또는 System.Management.Automation.RuntimeDefinedParameterDictionary 개체와 유사한 구문 분석 특성이 있는 속성과 필드가 있는 개체를 반환합니다. Windows PowerShell 런타임은 반환된 개체를 사용하여 cmdlet에 매개 변수를 추가합니다.
이 Windows PowerShell 컨테이너 공급자는 이 메서드를 구현하지 않습니다. 그러나 다음 코드는 이 메서드의 기본 구현입니다.
public object ClearContentDynamicParameters(string path)
{
return null;
}
public object ClearContentDynamicParameters(string path)
{
return null;
}
코드 샘플
전체 샘플 코드는 AccessDbProviderSample06 코드 샘플참조하세요.
개체 형식 및 서식 정의
공급자를 작성할 때 기존 개체에 멤버를 추가하거나 새 개체를 정의해야 할 수 있습니다. 이 작업이 완료되면 Windows PowerShell에서 개체의 멤버를 식별하는 데 사용할 수 있는 Types 파일과 개체 표시 방법을 정의하는 Format 파일을 만들어야 합니다. 자세한 내용은 개체 형식 확장 및 서식 참조하세요.
Windows PowerShell 공급자 빌드
Cmdlet, 공급자 및 호스트 애플리케이션등록하는 방법을 참조하세요.
Windows PowerShell 공급자 테스트
Windows PowerShell 공급자가 Windows PowerShell에 등록된 경우 명령줄에서 지원되는 cmdlet을 실행하여 테스트할 수 있습니다. 예를 들어 샘플 콘텐츠 공급자를 테스트합니다.
Get-Content
cmdlet을 사용하여 Path
매개 변수로 지정된 경로의 데이터베이스 테이블에서 지정된 항목의 내용을 검색합니다.
ReadCount
매개 변수는 정의된 콘텐츠 판독기에서 읽을 항목 수를 지정합니다(기본값 1). 다음 명령 항목을 사용하여 cmdlet은 테이블에서 두 개의 행(항목)을 검색하고 해당 내용을 표시합니다. 다음 예제 출력에서는 가상의 Access 데이터베이스를 사용합니다.
Get-Content -Path mydb:\Customers -ReadCount 2
ID : 1
FirstName : Eric
LastName : Gruber
Email : ericgruber@fabrikam.com
Title : President
Company : Fabrikam
WorkPhone : (425) 555-0100
Address : 4567 Main Street
City : Buffalo
State : NY
Zip : 98052
Country : USA
ID : 2
FirstName : Eva
LastName : Corets
Email : evacorets@cohowinery.com
Title : Sales Representative
Company : Coho Winery
WorkPhone : (360) 555-0100
Address : 8910 Main Street
City : Cabmerlot
State : WA
Zip : 98089
Country : USA
또한 참조하십시오
Cmdlet, 공급자 및 호스트 애플리케이션 등록하는 방법
Windows PowerShell SDK
PowerShell