大网数据广告活动
网络与域名解析

Using WMI Windows PowerShell Cmdlets to Manage the BITS Compact Server

· 52CE 我爱测

Windows PowerShell provides a simple mechanism to connect to Windows Management Instrumentation (WMI) on a remote computer and manage the Background Intelligent Transfer Service (BITS) Compact Server.

Windows PowerShell provides a simple mechanism to connect to Windows Management Instrumentation (WMI) on a remote computer and manage the Background Intelligent Transfer Service (BITS) Compact Server. The BITS Compact Server is an optional server component that must be installed separately. For information about installing the Compact Server, see the BITS Compact Server documentation.

  1. Connect to the BITS provider.

    $cred = Get-Credential
    $bcs = Get-WmiObject -Namespace "root\Microsoft\BITS" -Class "BITSCompactServerUrlGroup" `
    -List -ComputerName Server1 -Credential $cred
    

    The Get-Credential cmdlet requests the user's credentials to connect to the remote computer and assigns the credentials to the $cred object.

    The objects returned by the Get-WmiObject cmdlet are assigned to the $bcs variable. In the preceding example, the Get-WmiObject cmdlet retrieves the BITSCompactServerUrlGroup class in the root\Microsoft\BITS namespace of Server1. Static methods exposed by the BITSCompactServerUrlGroup class can be called on the $bcs object. For more information about BITS remote management, see BITS provider and BITS provider classes.

    [!Note]
    The grave-accent character (`) is used to indicate a line break.

  2. Create a URL group on the server.

    $URLGroup = "https://Server1:80/testurlgroup" 
    $bcs.CreateUrlGroup($URLGroup)
    

    The "https://Server1:80/testurlgroup" URL prefix string is assigned to the $URLGroup variable. The $URLGroup variable is passed to the CreateUrlGroup method, which creates the URL group on Server1.

    You can specify a different URL group. The URL group must conform to a valid URL prefix string. For more information about URL prefixes, see UrlPrefix Strings.

  3. Host a file on the URL group.

    $bcsObj = Get-WmiObject -Namespace "root\Microsoft\BITS" -Class "BITSCompactServerUrlGroup" -filter ("UrlGroup='" + $URLGroup + "'") -ComputerName Server1 -Credential $cred
    $bcsObj.CreateURL("url.txt", "c:\\temp\\1.txt", "") -ComputerName Server1 -Credential $cred
    

    The BITSCompactServerUrlGroup instance returned by the Get-WmiObject cmdlet is assigned to the $bcsObj variable. The CreateUrl method is called for the $bcsObj with the "url.txt" URL suffix, the "c:\\temp\\1.txt" source path for the file, and an empty security descriptor string as parameters. The "url.txt" suffix is added to the URL group prefix. Clients can download the file from the following address: https://Server1:80/testurlgroup/url.txt.

  4. Clean up the URL and the URL group.

    $bcsObj.Delete()
    

    The system.object Delete method deletes the $bcsObj object.

Related topics

BITS Compact Server

BITS provider

BITS provider classes

Get-Credential

Get-WmiObject

Source: Microsoft Learn / Windows Win32 documentation by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Win32 documentation
适用范围
Windows Win32 API · Source date 05/31/2018
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。