[置顶] [27] Window PowerShell DSC 学习系列----DSC 5.x 查询节点注册和执行报告(Report)查询

标签: PowerShell DSCoDataReport
1554人阅读 评论(0) 收藏 举报
分类:

我们知道,一旦我们把DSCD额Pull服务器安装成功,且目标节点也注册成功后,我们就可以调用DSC服务的oData的查询。去查询一些信息。


@查询节点的注册信息

如果已知AgentID,可以查询节点相关的注册信息。比如下面能查到当前的目标节点的相关信息,比如,计算机名字,IP地址,注册的ConfigurationName的名字是。

请注意,浏览器可能不支持oData的Http的get操作。因此笔者借助了第三方的HTTP的发送工具,比如,Advanced REST Client,注意请在HTTP的头里面加入:

Protocolversion: 2.0
accept: application/json;odata=minimalmetadata;streaming=true;charset=utf-8


例子:

http://test-dsc-server:8082/PSDSCPullServer.svc/Nodes(AgentId='304DC9EE-12D4-11E7-80B8-B9D2EE16DFC9')

返回结果:

{
"AgentId": "304DC9EE-12D4-11E7-80B8-B9D2EE16DFC9"
"AgentInformation": 
{
"LCMVersion": "2.0"
"NodeName": "TEST-DSC-CLIENT"
"IPAddress": "192.168.1.89;127.0.0.1;fe80::787f:37f6:2981:2e05%12;::2000:0:0:0;::1;::2000:0:0:0;2001:0:9d38:6ab8:3c85:2910:3f57:fea6;fe80::3c85:2910:3f57:fea6%14"
}
"ConfigurationNames": 
  "unzipFile"
"RegistrationInformation": 
{
"RegistrationMessageType": null
"CertificateInformation": null
}
"AdditionalData": 
}

@查询节点的执行结果信息

如果已知AgentID,可以查询节点相关的执行结果。

例子:

在浏览器里面打开:

http://test-DSC-SERVER:8082/PSDSCPullServer.svc/Nodes(AgentId='304DC9EE-12D4-11E7-80B8-B9D2EE16DFC9')/Reports


返回结果:

<?xml version="1.0" encoding="utf-8"?>
<feed xml:base="http://test-dsc-server:8082/PSDSCPullServer.svc/"
	xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
	xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
	xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml">
	<id>http://test-dsc-server:8082/PSDSCPullServer.svc/Nodes(AgentId='304DC9EE-12D4-11E7-80B8-B9D2EE16DFC9')/Reports
	</id>
	<title type="text">Reports</title>
	<updated>2017-04-17T07:19:04Z</updated>
	<link rel="self" title="Reports" href="Reports" />
	<entry>
		<id>http://test-dsc-server:8082/PSDSCPullServer.svc/Reports('e7a0061d-233d-11e7-80b9-c7047977fc22')
		</id>
		<category term="MSFT.DSCReport"
			scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
		<link rel="edit" title="DSCReport"
			href="Reports('e7a0061d-233d-11e7-80b9-c7047977fc22')" />
		<link
			rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Nodes"
			type="application/atom+xml;type=entry" title="Nodes"
			href="Reports('e7a0061d-233d-11e7-80b9-c7047977fc22')/Nodes" />
		<title />
		<updated>2017-04-17T07:19:04Z</updated>
		<author>
			<name />
		</author>
		<content type="application/xml">
			<m:properties>
				<d:JobId>e7a0061d-233d-11e7-80b9-c7047977fc22</d:JobId>
				<d:OperationType>LocalConfigurationManager</d:OperationType>
				<d:RefreshMode>Pull</d:RefreshMode>
				<d:Status>Success</d:Status>
				<d:ReportFormatVersion>2.0</d:ReportFormatVersion>
				<d:ConfigurationVersion>2.0.0</d:ConfigurationVersion>
				<d:StartTime m:type="Edm.DateTime">2017-04-17T07:17:50</d:StartTime>
				<d:EndTime m:type="Edm.DateTime">2017-04-17T07:18:11</d:EndTime>
				<d:RebootRequested>False</d:RebootRequested>
				<d:Errors m:type="Collection(Edm.String)" />
				<d:StatusData m:type="Collection(Edm.String)">
					<d:element>{"StartDate":"2017-04-17T07:17:50.7050000+00:00","IPV6Addresses":["fe80::787f:37f6:2981:2e05%12","::2000:0:0:0","::1","::2000:0:0:0","2001:0:9d38:6ab8:3c85:2910:3f57:fea6","fe80::3c85:2910:3f57:fea6%14"],"DurationInSeconds":"21","JobID":"{E7A0061D-233D-11E7-80B9-C7047977FC22}","CurrentChecksum":"63606109E45835E2F508D95CB00A61203549AD96E6EABF2BC647230DA6357A0F","MetaData":"Author:
						Administrator; Name: PullClientConfigNames; Version: 2.0.0;
						GenerationDate: 04/17/2017 07:17:24; GenerationHost:
						test-DSC-CLIENT;","Status":"Success","IPV4Addresses":["192.168.1.89","127.0.0.1"],"LCMVersion":"2.0","NumberOfResources":"0","Type":"LocalConfigurationManager","HostName":"test-DSC-CLIENT","RebootRequested":"False","MACAddresses":["FA-16-3E-7B-59-B6","00-00-00-00-00-00-00-E0","00-00-00-00-00-00-00-E0"],"MetaConfiguration":{"AgentId":"304DC9EE-12D4-11E7-80B8-B9D2EE16DFC9","ConfigurationDownloadManagers":[{"SourceInfo":"C:\\dsc\\registerto2.55AccessSQLServer.ps1::18::9::ConfigurationRepositoryWeb","AllowUnsecureConnection":"True","ServerURL":"http://test-DSC-SERVER:8082/PSDSCPullServer.svc","RegistrationKey":"","ResourceId":"[ConfigurationRepositoryWeb]pull51w2k12nssl","ConfigurationNames":["unzipFile"]}],"ActionAfterReboot":"ContinueConfiguration","LCMCompatibleVersions":["1.0","2.0"],"LCMState":"Idle","ResourceModuleManagers":[],"ReportManagers":[{"AllowUnsecureConnection":"True","RegistrationKey":"","ServerURL":"http://test-DSC-SERVER:8082/PSDSCPullServer.svc","ResourceId":"[ReportServerWeb]pull51w2k12nssl","SourceInfo":"C:\\dsc\\registerto2.55AccessSQLServer.ps1::28::9::ReportServerWeb"}],"StatusRetentionTimeInDays":"10","LCMVersion":"2.0","MaximumDownloadSizeMB":"500","ConfigurationMode":"ApplyAndAutoCorrect","RefreshFrequencyMins":"30","RebootNodeIfNeeded":"True","SignatureValidationPolicy":"NONE","RefreshMode":"Pull","DebugMode":["ForceModuleImport"],"LCMStateDetail":"","AllowModuleOverwrite":"False","ConfigurationModeFrequencyMins":"15","SignatureValidations":[]},"Locale":"en-US","Mode":"Pull"}
					</d:element>
				</d:StatusData>
				<d:AdditionalData m:type="Collection(MSFT.PropertyBag)">
					<d:element>
						<d:Key>OSVersion</d:Key>
						<d:Value>{"VersionString":"Microsoft Windows NT
							6.3.9600.0","ServicePack":"","Platform":"Win32NT"}</d:Value>
					</d:element>
					<d:element>
						<d:Key>PSVersion</d:Key>
						<d:Value>{"CLRVersion":"4.0.30319.42000","PSVersion":"5.1.14409.1005","BuildVersion":"10.0.14409.1005"}
						</d:Value>
					</d:element>
				</d:AdditionalData>
			</m:properties>
		</content>
	</entry>
	<entry>
		<id>http://test-dsc-server:8082/PSDSCPullServer.svc/Reports('03c765d9-233e-11e7-80b9-c7047977fc22')
		</id>
		<category term="MSFT.DSCReport"
			scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
		<link rel="edit" title="DSCReport"
			href="Reports('03c765d9-233e-11e7-80b9-c7047977fc22')" />
		<link
			rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Nodes"
			type="application/atom+xml;type=entry" title="Nodes"
			href="Reports('03c765d9-233e-11e7-80b9-c7047977fc22')/Nodes" />
		<title />
		<updated>2017-04-17T07:19:04Z</updated>
		<author>
			<name />
		</author>
		<content type="application/xml">
			<m:properties>
				<d:JobId>03c765d9-233e-11e7-80b9-c7047977fc22</d:JobId>
				<d:OperationType>Initial</d:OperationType>
				<d:RefreshMode>Pull</d:RefreshMode>
				<d:Status>Success</d:Status>
				<d:ReportFormatVersion>2.0</d:ReportFormatVersion>
				<d:ConfigurationVersion>2.0.0</d:ConfigurationVersion>
				<d:StartTime m:type="Edm.DateTime">2017-04-17T07:18:12</d:StartTime>
				<d:EndTime m:type="Edm.DateTime">2017-04-17T07:18:14</d:EndTime>
				<d:RebootRequested>False</d:RebootRequested>
				<d:Errors m:type="Collection(Edm.String)" />
				<d:StatusData m:type="Collection(Edm.String)">
					<d:element>{"StartDate":"2017-04-17T07:18:12.6580000+00:00","IPV6Addresses":["fe80::787f:37f6:2981:2e05%12","::2000:0:0:0","::1","::2000:0:0:0","2001:0:9d38:6ab8:3c85:2910:3f57:fea6","fe80::3c85:2910:3f57:fea6%14"],"DurationInSeconds":"2","JobID":"{03C765D9-233E-11E7-80B9-C7047977FC22}","CurrentChecksum":"701051B61256AC25CBEAE0A83AF5F06CD626D6F26CD23F03ECD5C2D524194479","MetaData":"Author:
						Administrator; Name: testzip; Version: 2.0.0; GenerationDate:
						04/17/2017 07:16:38; GenerationHost:
						test-DSC-SERVER;","RebootRequested":"False","Status":"Success","IPV4Addresses":["192.168.1.89","127.0.0.1"],"LCMVersion":"2.0","NumberOfResources":"1","Type":"Initial","HostName":"test-DSC-CLIENT","ResourcesInDesiredState":[{"SourceInfo":"C:\\Program
						Files\\WindowsPowerShell\\Modules\\xPSDesiredStateConfiguration\\5.1.0.0\\DSCResources\\MSFT_xDSCWebService\\pubmof.ps1::5::7::Archive","ModuleName":"PSDesiredStateConfiguration","DurationInSeconds":"1.219","InstanceName":"ArchiveExample","StartDate":"2017-04-17T07:18:13.9080000+00:00","ResourceName":"Archive","ModuleVersion":"1.1","RebootRequested":"False","ResourceId":"[Archive]ArchiveExample","ConfigurationName":"testzip","InDesiredState":"True"}],"MACAddresses":["FA-16-3E-7B-59-B6","00-00-00-00-00-00-00-E0","00-00-00-00-00-00-00-E0"],"MetaConfiguration":{"AgentId":"304DC9EE-12D4-11E7-80B8-B9D2EE16DFC9","ConfigurationDownloadManagers":[{"SourceInfo":"C:\\dsc\\registerto2.55AccessSQLServer.ps1::18::9::ConfigurationRepositoryWeb","AllowUnsecureConnection":"True","ServerURL":"http://test-DSC-SERVER:8082/PSDSCPullServer.svc","RegistrationKey":"","ResourceId":"[ConfigurationRepositoryWeb]pull51w2k12nssl","ConfigurationNames":["unzipFile"]}],"ActionAfterReboot":"ContinueConfiguration","LCMCompatibleVersions":["1.0","2.0"],"LCMState":"Idle","ResourceModuleManagers":[],"ReportManagers":[{"AllowUnsecureConnection":"True","RegistrationKey":"","ServerURL":"http://test-DSC-SERVER:8082/PSDSCPullServer.svc","ResourceId":"[ReportServerWeb]pull51w2k12nssl","SourceInfo":"C:\\dsc\\registerto2.55AccessSQLServer.ps1::28::9::ReportServerWeb"}],"StatusRetentionTimeInDays":"10","LCMVersion":"2.0","MaximumDownloadSizeMB":"500","ConfigurationMode":"ApplyAndAutoCorrect","RefreshFrequencyMins":"30","RebootNodeIfNeeded":"True","SignatureValidationPolicy":"NONE","RefreshMode":"Pull","DebugMode":["ForceModuleImport"],"LCMStateDetail":"","AllowModuleOverwrite":"False","ConfigurationModeFrequencyMins":"15","SignatureValidations":[]},"Locale":"en-US","Mode":"Pull"}
					</d:element>
				</d:StatusData>
				<d:AdditionalData m:type="Collection(MSFT.PropertyBag)">
					<d:element>
						<d:Key>OSVersion</d:Key>
						<d:Value>{"VersionString":"Microsoft Windows NT
							6.3.9600.0","ServicePack":"","Platform":"Win32NT"}</d:Value>
					</d:element>
					<d:element>
						<d:Key>PSVersion</d:Key>
						<d:Value>{"CLRVersion":"4.0.30319.42000","PSVersion":"5.1.14409.1005","BuildVersion":"10.0.14409.1005"}
						</d:Value>
					</d:element>
				</d:AdditionalData>
			</m:properties>
		</content>
	</entry>
</feed>
1
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:386735次
    • 积分:6358
    • 等级:
    • 排名:第4108名
    • 原创:228篇
    • 转载:0篇
    • 译文:5篇
    • 评论:157条
    博客专栏