Uwaga
Dostęp do tej strony wymaga autoryzacji. Może spróbować zalogować się lub zmienić katalogi.
Dostęp do tej strony wymaga autoryzacji. Możesz spróbować zmienić katalogi.
Miesięczne informacje podsumowania użycia są wyświetlane w Configuration Manager przy użyciu klas SMS_MeteredFiles, SMS_MonthlyUsageSummary, SMS_MeteredUser i SMS_R_System.
Uwaga
Dane pomiaru są sumowane tylko w określonych interwałach (domyślnie codziennie o północy). Dane pomiarowe nie są wyświetlane w podsumowanych danych, dopóki zadanie podsumowania nie zostanie uruchomione.
Aby wyświetlić informacje o miesięcznym podsumowaniu użycia
Skonfiguruj połączenie z dostawcą programu SMS.
Pobierz wszystkie pliki taryfowe (SMS_MeteredFiles).
Pobierz wszystkie miesięczne informacje o podsumowaniu użycia plików (SMS_MonthlyUsageSummary).
Pobierz wszystkich użytkowników taryfowych (SMS_MeteredUser).
Pobierz wszystkie nazwy komputerów (SMS_R_System).
Przeprowadź pętlę przez kolekcje, wyświetlając informacje zgodnie z wymaganiami.
Przykład
Poniższa przykładowa metoda wyświetla informacje podsumowania użycia plików przy użyciu klas SMS_MeteredFiles i SMS_FileUsageSummary .
Aby uzyskać informacje na temat wywoływania przykładowego kodu, zobacz Wywoływanie fragmentów kodu Configuration Manager.
Sub ViewMonthlySummary(connection)
' Get SMS_MeteredFiles - used to match FileID to a file name
' Build query to get all metered files.
meteredFilesQuery = "SELECT * FROM SMS_MeteredFiles"
' Run query.
Set meteredFiles = connection.ExecQuery(meteredFilesQuery, , wbemFlagForwardOnly Or wbemFlagReturnImmediately)
' Get SMS_MonthlyUsageSummary
' Build query to get all monthly summary information.
monthlyUsageSummaryQuery = "SELECT * FROM SMS_MonthlyUsageSummary"
' Run query.
Set monthlyUsageSummaries = connection.ExecQuery(monthlyUsageSummaryQuery, , wbemFlagForwardOnly Or wbemFlagReturnImmediately)
'Get SMS_MeteredUser
' Build query to get all metered users.
meteredUserQuery = "SELECT * FROM SMS_MeteredUser"
' Run query.
Set meteredUsers = connection.ExecQuery(meteredUserQuery, , wbemFlagForwardOnly Or wbemFlagReturnImmediately)
'Get computer names
' Build query to get all metered computers.
meteredComputerQuery = "SELECT * FROM SMS_R_System"
' Run query.
Set meteredComputers = connection.ExecQuery(meteredComputerQuery, , wbemFlagForwardOnly Or wbemFlagReturnImmediately)
For Each summary in monthlyUsageSummaries
For each meteredFile in meteredFiles
if meteredFile.MeteredFileID=summary.FileID then
wscript.echo "File Name:" & meteredFile.FileName
Exit For
end if
next
for each meteredUser in meteredUsers
if meteredUser.MeteredUserID=summary.MeteredUserID then
wscript.echo "User Name: " & meteredUser.FullName
Exit For
end if
next
wscript.echo "Usage Count:" & summary.UsageCount
wscript.echo "Terminal Service Usage Count:" & summary.TSUsageCount
for each computer in meteredComputers
if computer.ResourceId=summary.ResourceID then
wscript.echo "Computer:" & computer.Name
Exit For
end if
next
wscript.echo
Next
end sub
public void ViewMonthlySummaryInfo(WqlConnectionManager connection)
{
try
{
// Get SMS_MeteredFiles - used to match FileID to a file name.
// Build query to get all metered files.
string meteredFilesQuery = "SELECT * FROM SMS_MeteredFiles";
// Run meteredFiles query.
IResultObject meteredFiles = connection.QueryProcessor.ExecuteQuery(meteredFilesQuery);
// Get SMS_MonthlyUsageSummary.
// Build query to get all of the monthly file usage summary information.
string monthlyUsageSummaryQuery = "SELECT * FROM SMS_MonthlyUsageSummary";
// Run monthlyUsageSummaryQuery query.
IResultObject monthlyUsageSummaries = connection.QueryProcessor.ExecuteQuery(monthlyUsageSummaryQuery);
// Get SMS_MeteredUsers.
// Build query to get all of the metered users.
string meteredUserQuery = "SELECT * FROM SMS_MeteredUser";
// Run meteredUser query.
IResultObject meteredUsers = connection.QueryProcessor.ExecuteQuery(meteredUserQuery);
// Get computer names.
// Build query to get all the metered computers.
string meteredComputersQuery = "SELECT * FROM SMS_R_System";
// Run fileUsageSummary query.
IResultObject meteredComputers = connection.QueryProcessor.ExecuteQuery(meteredComputersQuery);
// Enumerate through the lists, outputs results as matches are found.
foreach (IResultObject summary in monthlyUsageSummaries)
{
foreach (IResultObject meteredFile in meteredFiles)
{
if (meteredFile["MeteredFileID"].StringValue == summary["FileID"].StringValue)
{
Console.WriteLine("File Name: " + meteredFile["FileName"].StringValue);
break;
};
};
foreach(IResultObject meteredUser in meteredUsers)
{
if (meteredUser["MeteredUserID"].StringValue == summary["MeteredUserID"].StringValue)
{
Console.WriteLine("User Name: " + meteredUser["FullName"].StringValue);
break;
}
};
Console.WriteLine("Usage Count: " + summary["UsageCount"].StringValue);
Console.WriteLine("Terminal Service Usage Count: " + summary["TSUsageCount"].StringValue);
foreach(IResultObject computer in meteredComputers)
{
if(computer["ResourceId"].StringValue == summary["ResourceID"].StringValue)
{
Console.WriteLine("Computer: " + computer["Name"].StringValue);
break;
}
};
//
Console.WriteLine(" ");
};
}
catch (SmsException ex)
{
Console.WriteLine("Failed. Error: " + ex.InnerException.Message);
throw;
}
}
Przykładowa metoda ma następujące parametry:
Parametr | Wpisać | Opis |
---|---|---|
connection |
— Zarządzane: WqlConnectionManager - VBScript: SWbemServices |
Prawidłowe połączenie z dostawcą programu SMS. |
Kompilowanie kodu
Ten przykład języka C# wymaga:
Obszary nazw
System
System.collections.generic
System.text
Microsoft.ConfigurationManagement.ManagementProvider
Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine
Zestawu
adminui.wqlqueryengine
microsoft.configurationmanagement.managementprovider
Niezawodne programowanie
Aby uzyskać więcej informacji na temat obsługi błędów, zobacz Informacje o błędach Configuration Manager.
zabezpieczenia .NET Framework
Aby uzyskać więcej informacji na temat zabezpieczania aplikacji Configuration Manager, zobacz Configuration Manager administracja oparta na rolach.
Zobacz też
zestaw Configuration Manager Software Development Kit
SMS_MeteredFiles Server WMI Class
SMS_MeteredUser Server WMI Class
SMS_MonthlyUsageSummary Server WMI Class
SMS_R_System Server WMI Class
SMS_SummarizationInterval Server WMI Class