---
updatedAt: 2025-08-14T13:33:20.000Z
agentTools:
  siteIndex: https://developer.n-able.com/llms.txt
  projectIndex: https://developer.n-able.com/n-central/llms.txt
---

# Name Change monitoring

```powershell AMP
<Policy ID="{6d8b75ee-1b22-407f-8eb2-6fc3b933955f}" Name="NameChange" Description="Q2hlY2tzIGlmIG5hbWUgd2FzIGNoYW5nZWQgb2YgdGhlIGRldmljZSAocHJldmlvdXNseSBuYW1lIGlzIHN0b3JlZCBpbiBjdXN0b21lciBXTUkgY2xhc3MgLSByb290XGNpbXYyXG5jZW50cmFsKQ0KDQojdjEuMA0KQ3JlYXRlZCBmb3IgdGhlIGNvbW11bml0eSBieQ0KLSBWQlMgOiBUaW0gV2lzZXIgLSBPcmNoaWQNCi0gQU1QIDogV2ltIExhbW90IC0gQWNjZWwgQ29tcHV0ZXIgU2VydmljZQ0KLSBYTUwgOiBUaW0gV2lzZXIgJiBXaW0gTGFtb3Q=" Version="1.2.0.20">
  <Object ID="{b3d8f34d-ddf8-4319-a08c-54399662e376}" Type="{B6FA6D8B-EEAA-47A6-8463-7F9A4F5BBB6E}" Data="&lt;xml /&gt;" />
  <LinkManager xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/DesignerHost.Model">
    <hashset xmlns:d2p1="http://schemas.datacontract.org/2004/07/System">
      <d2p1:TupleOfstringstringstringstring>
        <d2p1:m_Item1>0c9b94ef-844e-4a68-bdeb-419b6587f3c3</d2p1:m_Item1>
        <d2p1:m_Item2>d88c78be-dbdd-48ca-9958-a41d96e9d008</d2p1:m_Item2>
        <d2p1:m_Item3>PolicyExecutor.IfObject, PolicyExecutionEngine, Version=1.2.0.20, Culture=neutral, PublicKeyToken=null</d2p1:m_Item3>
        <d2p1:m_Item4>VariableString</d2p1:m_Item4>
      </d2p1:TupleOfstringstringstringstring>
      <d2p1:TupleOfstringstringstringstring>
        <d2p1:m_Item1>ffb4ad5c-a91e-4894-b344-432328313280</d2p1:m_Item1>
        <d2p1:m_Item2>3ea21824-1a32-45fa-97b9-cc4f478740ae</d2p1:m_Item2>
        <d2p1:m_Item3>PolicyExecutor.RunScript, PolicyExecutionEngine, Version=1.2.0.20, Culture=neutral, PublicKeyToken=null</d2p1:m_Item3>
        <d2p1:m_Item4>ScriptComputerName</d2p1:m_Item4>
      </d2p1:TupleOfstringstringstringstring>
      <d2p1:TupleOfstringstringstringstring>
        <d2p1:m_Item1>0c9b94ef-844e-4a68-bdeb-419b6587f3c3</d2p1:m_Item1>
        <d2p1:m_Item2>f00c18d6-3f14-42a1-a4f1-5df6c0e58b22</d2p1:m_Item2>
        <d2p1:m_Item3>PolicyExecutor.IfObject, PolicyExecutionEngine, Version=1.2.0.20, Culture=neutral, PublicKeyToken=null</d2p1:m_Item3>
        <d2p1:m_Item4>VariableString</d2p1:m_Item4>
      </d2p1:TupleOfstringstringstringstring>
      <d2p1:TupleOfstringstringstringstring>
        <d2p1:m_Item1>ffb4ad5c-a91e-4894-b344-432328313280</d2p1:m_Item1>
        <d2p1:m_Item2>f9ea6797-d777-483d-887f-f2676b52a222</d2p1:m_Item2>
        <d2p1:m_Item3>PolicyExecutor.IfElse, PolicyExecutionEngine, Version=1.2.0.20, Culture=neutral, PublicKeyToken=null</d2p1:m_Item3>
        <d2p1:m_Item4>VariableString</d2p1:m_Item4>
      </d2p1:TupleOfstringstringstringstring>
      <d2p1:TupleOfstringstringstringstring>
        <d2p1:m_Item1>0c9b94ef-844e-4a68-bdeb-419b6587f3c3</d2p1:m_Item1>
        <d2p1:m_Item2>f9ea6797-d777-483d-887f-f2676b52a222</d2p1:m_Item2>
        <d2p1:m_Item3>PolicyExecutor.IfElse, PolicyExecutionEngine, Version=1.2.0.20, Culture=neutral, PublicKeyToken=null</d2p1:m_Item3>
        <d2p1:m_Item4>ValueString</d2p1:m_Item4>
      </d2p1:TupleOfstringstringstringstring>
      <d2p1:TupleOfstringstringstringstring>
        <d2p1:m_Item1>ffb4ad5c-a91e-4894-b344-432328313280</d2p1:m_Item1>
        <d2p1:m_Item2>51f10271-9b74-4402-8d33-733ee7a9848d</d2p1:m_Item2>
        <d2p1:m_Item3>PolicyExecutor.RunScript, PolicyExecutionEngine, Version=1.2.0.20, Culture=neutral, PublicKeyToken=null</d2p1:m_Item3>
        <d2p1:m_Item4>ScriptNotChangedComputerName</d2p1:m_Item4>
      </d2p1:TupleOfstringstringstringstring>
      <d2p1:TupleOfstringstringstringstring>
        <d2p1:m_Item1>ffb4ad5c-a91e-4894-b344-432328313280</d2p1:m_Item1>
        <d2p1:m_Item2>c6473b8a-3499-461f-85fe-ec3bc4ae689c</d2p1:m_Item2>
        <d2p1:m_Item3>PolicyExecutor.RunScript, PolicyExecutionEngine, Version=1.2.0.20, Culture=neutral, PublicKeyToken=null</d2p1:m_Item3>
        <d2p1:m_Item4>ScriptComputerNameIsChanged</d2p1:m_Item4>
      </d2p1:TupleOfstringstringstringstring>
      <d2p1:TupleOfstringstringstringstring>
        <d2p1:m_Item1>ffb4ad5c-a91e-4894-b344-432328313280</d2p1:m_Item1>
        <d2p1:m_Item2>57fc3cd3-291b-4ceb-97b1-1362dc8504f7</d2p1:m_Item2>
        <d2p1:m_Item3>PolicyExecutor.Log, PolicyExecutionEngine, Version=1.2.0.20, Culture=neutral, PublicKeyToken=null</d2p1:m_Item3>
        <d2p1:m_Item4>Message</d2p1:m_Item4>
      </d2p1:TupleOfstringstringstringstring>
      <d2p1:TupleOfstringstringstringstring>
        <d2p1:m_Item1>0c9b94ef-844e-4a68-bdeb-419b6587f3c3</d2p1:m_Item1>
        <d2p1:m_Item2>b43d2816-f522-410b-8438-c6e2a16caa33</d2p1:m_Item2>
        <d2p1:m_Item3>PolicyExecutor.Log, PolicyExecutionEngine, Version=1.2.0.20, Culture=neutral, PublicKeyToken=null</d2p1:m_Item3>
        <d2p1:m_Item4>Message</d2p1:m_Item4>
      </d2p1:TupleOfstringstringstringstring>
    </hashset>
  </LinkManager>
  <Activity mc:Ignorable="sap" x:Class="Policy Builder" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mva="clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities" xmlns:p="clr-namespace:PolicyExecutor;assembly=PolicyExecutionEngine" xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation" xmlns:scg="clr-namespace:System.Collections.Generic;assembly=mscorlib" xmlns:sco="clr-namespace:System.Collections.ObjectModel;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <x:Members>
      <x:Property Name="PolicyGUID" Type="InArgument(x:String)" />
    </x:Members>
    <sap:VirtualizedContainerService.HintSize>974,2367</sap:VirtualizedContainerService.HintSize>
    <mva:VisualBasic.Settings>Assembly references and imported namespaces serialized as XML namespaces</mva:VisualBasic.Settings>
    <p:PolicySequence DisplayName="Policy" sap:VirtualizedContainerService.HintSize="934,2327" mva:VisualBasic.Settings="Assembly references and imported namespaces serialized as XML namespaces">
      <p:PolicySequence.Activities>
        <p:GetEnvironmentVariable Computer_Item="{x:Null}" Computer_ItemProp="{x:Null}" Variable_Item="{x:Null}" Variable_ItemProp="{x:Null}" Computer="localhost" Computer_DisplayArg="localhost" DisplayName="Gets the local ComputerName" sap:VirtualizedContainerService.HintSize="914,98" Moniker="ffb4ad5c-a91e-4894-b344-432328313280" Result="[GetEnvironmentVariable_Result_1]" ScriptDirectory="goog" Type="Process" TypeName="GetEnvironmentVariable" Value="[GetEnvironmentVariable_Value_0]" Variable="Computername" Variable_DisplayArg="Computername" m_bTextLinkChange="False" />
        <p:RunScript genArgEvent="{x:Null}" DisplayName="Checks if Namespace NCentral Exists WMI" sap:VirtualizedContainerService.HintSize="914,218" Moniker="299fb0a9-4786-4b48-95e6-9992cdcdd6fa" Result="[RunScript_Result_2]" ScriptDirectory="goog" TypeName="RunScript" m_bTextLinkChange="False" script="SWYgKEdldC1XbWlPYmplY3QgLU5hbWVzcGFjZSAicm9vdFxjaW12MiIgLUNsYXNzICJfX05BTUVTUEFDRSIgfCBXaGVyZS1PYmplY3QgeyRfLk5hbWUgLWVxICJOY2VudHJhbCJ9KQ0Kew0KICAgIFdSSVRFLUhPU1QgIlRoZSByb290XGNpbXYyXE5jZW50cmFsIFdNSSBuYW1lc3BhY2UgZXhpc3RzLiINCn0NCkVsc2UNCnsNCiAgICBXUklURS1IT1NUICJUaGUgcm9vdFxjaW12MlxOY2VudHJhbCBXTUkgbmFtZXNwYWNlIGRvZXMgbm90IGV4aXN0LiINCiAgICAkd21pPSBbd21pY2xhc3NdInJvb3RcY2ltdjI6X19OYW1lc3BhY2UiIA0KICAgICRuZXdOYW1lc3BhY2UgPSAkd21pLmNyZWF0ZUluc3RhbmNlKCkgDQogICAgJG5ld05hbWVzcGFjZS5uYW1lID0gIk5DZW50cmFsIiANCiAgICAkbmV3TmFtZXNwYWNlLnB1dCgpIA0KfQ==">
          <p:RunScript.InArgs>
            <scg:Dictionary x:TypeArguments="x:String, p:InArg" />
          </p:RunScript.InArgs>
          <p:RunScript.OutArgs>
            <scg:Dictionary x:TypeArguments="x:String, p:OutArg" />
          </p:RunScript.OutArgs>
        </p:RunScript>
        <p:RunScript genArgEvent="{x:Null}" DisplayName="Checks if Class NameChange Exists in WMI and output StoredName if Exists" sap:VirtualizedContainerService.HintSize="914,218" Moniker="0c9b94ef-844e-4a68-bdeb-419b6587f3c3" Result="[RunScript_Result_0]" ScriptDirectory="goog" TypeName="RunScript" m_bTextLinkChange="False" script="IyBDaGVjayB0byBzZWUgaWYgdGhlICdOYW1lQ2hhbmdlJyBjbGFzcyBleGlzdHMgLSBpZiBpdCBkb2Vzbid0LCB0aGVuIGxldCdzIGNyZWF0ZSBpdA0KSWYgKEdldC1XbWlPYmplY3QgLUxpc3QgLU5hbWVzcGFjZSAicm9vdFxjaW12MlxOY2VudHJhbCIgfCBXaGVyZS1PYmplY3QgeyRfLk5hbWUgLWVxICJOYW1lQ2hhbmdlIn0pDQp7DQogICAgV1JJ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WVDaGFuZ2UiOyANCiAgICAkc3ViQ2xhc3MuUHJvcGVydGllcy5BZGQoIkluZGV4IiwgW1N5c3RlbS5NYW5hZ2VtZW50LkNpbVR5cGVdOjpVSW50MzIsICRmYWxzZSkNCiAgICAkc3ViQ2xhc3MuUHJvcGVydGllc1siSW5kZXgiXS5RdWFsaWZpZXJzLkFkZCgiS2V5IiwgJHRydWUpDQogICAgJHN1YkNsYXNzLlByb3BlcnRpZXMuQWRkKCJTdG9yZWROYW1lIiwgW1N5c3RlbS5NYW5hZ2VtZW50LkNpbVR5cGVdOjpTdHJpbmcsICRmYWxzZSkNCiAgICAkc3ViQ2xhc3MuUHJvcGVydGllcy5BZGQoIk5hbWVIYXNDaGFuZ2VkIiwgW1N5c3RlbS5NYW5hZ2VtZW50LkNpbVR5cGVdOjpCb29sZWFuLCAkZmFsc2UpDQogICAgJHN1YkNsYXNzLlB1dCgpDQogICAgJCVpZCVTdG9yZWROYW1lJWlkJT0iTkFNRUNIQU5HRV9GSVJTVFJVTiINCn0=">
          <p:RunScript.InArgs>
            <scg:Dictionary x:TypeArguments="x:String, p:InArg" />
          </p:RunScript.InArgs>
          <p:RunScript.OutArgs>
            <p:OutArg x:Key="StoredName" ArgType="string" DisplayName="StoredName" Name="StoredName">
              <p:OutArg.Arg>
                <OutArgument x:TypeArguments="x:String">[RunScript_StoredName_1]</OutArgument>
              </p:OutArg.Arg>
            </p:OutArg>
          </p:RunScript.OutArgs>
        </p:RunScript>
        <p:IfObject ValueDate="{x:Null}" ValueDate_DisplayArg="{x:Null}" ValueDate_Item="{x:Null}" ValueDate_ItemProp="{x:Null}" ValueNum="{x:Null}" ValueNum_DisplayArg="{x:Null}" ValueNum_Item="{x:Null}" ValueNum_ItemProp="{x:Null}" ValueString_Item="{x:Null}" ValueString_ItemProp="{x:Null}" VariableDate="{x:Null}" VariableDate_DisplayArg="{x:Null}" VariableDate_Item="{x:Null}" VariableDate_ItemProp="{x:Null}" VariableNum="{x:Null}" VariableNum_DisplayArg="{x:Null}" VariableNum_Item="{x:Null}" VariableNum_ItemProp="{x:Null}" VariableString_Item="{x:Null}" VariableString_ItemProp="{x:Null}" Condition="equals" DisplayName="Fill up for the First time the Values for the StoredName when WMI at first run" sap:VirtualizedContainerService.HintSize="914,500" Moniker="d88c78be-dbdd-48ca-9958-a41d96e9d008" Result="[IfObject_Result_2]" ScriptDirectory="goog" Type="string" TypeName="IfObject" ValueString="NAMECHANGE_FIRSTRUN" ValueString_DisplayArg="NAMECHANGE_FIRSTRUN" VariableString="[RunScript_StoredName_1]" VariableString_DisplayArg="ChecksifClassNameChangeExistsinWMIandoutputStoredNameifExists.StoredName" m_bTextLinkChange="False">
          <p:IfObject.IfOption>
            <ActivityAction>
              <p:SequenceActivity DisplayName="Then" sap:VirtualizedContainerService.HintSize="418,340" Name="SequenceActivity">
                <p:SequenceActivity.Activities>
                  <p:RunScript DisplayName="Fills up the WMI with the computername from the first run" sap:VirtualizedContainerService.HintSize="398,218" Moniker="3ea21824-1a32-45fa-97b9-cc4f478740ae" Result="[RunScript_Result_5]" ScriptDirectory="goog" TypeName="RunScript" genArgEvent="19b1a577-df60-422a-9717-e76c351678d0" m_bTextLinkChange="False" script="JFB1c2hEYXRhVG9XTUkgPSAoW3dtaWNsYXNzXSJyb290XGNpbXYyXE5jZW50cmFsOk5hbWVDaGFuZ2UiKS5DcmVhdGVJbnN0YW5jZSgpDQokUHVzaERhdGFUb1dNSS5JbmRleCA9IDENCiRQdXNoRGF0YVRvV01JLlN0b3JlZE5hbWUgPSAiJCVpZCVTY3JpcHRDb21wdXRlck5hbWUlaWQlIg0KJFB1c2hEYXRhVG9XTUkuTmFtZUhhc0NoYW5nZWQgPSAwDQokUHVzaERhdGFUb1dNSS5QdXQoKQ==">
                    <p:RunScript.InArgs>
                      <p:InArg ItemProp="{x:Null}" x:Key="ScriptComputerName" ArgType="string" DisplayArg="GetsthelocalComputerName.Value" DisplayName="ScriptComputerName" Name="ScriptComputerName" isRequired="True" isRequiredDisplay="Yes">
                        <p:InArg.Arg>
                          <InArgument x:TypeArguments="x:String">[GetEnvironmentVariable_Value_0]</InArgument>
                        </p:InArg.Arg>
                        <p:InArg.Item>
                          <InArgument x:TypeArguments="x:Object" />
                        </p:InArg.Item>
                      </p:InArg>
                    </p:RunScript.InArgs>
                    <p:RunScript.OutArgs>
                      <scg:Dictionary x:TypeArguments="x:String, p:OutArg" />
                    </p:RunScript.OutArgs>
                  </p:RunScript>
                </p:SequenceActivity.Activities>
                <p:SequenceActivity.Variables>
                  <Variable x:TypeArguments="x:Double" Name="RunScript_Result_5" />
                </p:SequenceActivity.Variables>
              </p:SequenceActivity>
            </ActivityAction>
          </p:IfObject.IfOption>
        </p:IfObject>
        <p:IfObject ValueDate="{x:Null}" ValueDate_DisplayArg="{x:Null}" ValueDate_Item="{x:Null}" ValueDate_ItemProp="{x:Null}" ValueNum="{x:Null}" ValueNum_DisplayArg="{x:Null}" ValueNum_Item="{x:Null}" ValueNum_ItemProp="{x:Null}" ValueString_Item="{x:Null}" ValueString_ItemProp="{x:Null}" VariableDate="{x:Null}" VariableDate_DisplayArg="{x:Null}" VariableDate_Item="{x:Null}" VariableDate_ItemProp="{x:Null}" VariableNum="{x:Null}" VariableNum_DisplayArg="{x:Null}" VariableNum_Item="{x:Null}" VariableNum_ItemProp="{x:Null}" VariableString_Item="{x:Null}" VariableString_ItemProp="{x:Null}" Condition="does not equal" DisplayName="Now for value not like NAMECHANGE_FIRSTRUN means that we need to compare" sap:VirtualizedContainerService.HintSize="914,782" Moniker="f00c18d6-3f14-42a1-a4f1-5df6c0e58b22" Result="[IfObject_Result_6]" ScriptDirectory="goog" Type="string" TypeName="IfObject" ValueString="NAMECHANGE_FIRSTRUN" ValueString_DisplayArg="NAMECHANGE_FIRSTRUN" VariableString="[RunScript_StoredName_1]" VariableString_DisplayArg="ChecksifClassNameChangeExistsinWMIandoutputStoredNameifExists.StoredName" m_bTextLinkChange="False">
          <p:IfObject.IfOption>
            <ActivityAction>
              <p:SequenceActivity DisplayName="Then" sap:VirtualizedContainerService.HintSize="890,622" Name="SequenceActivity">
                <p:SequenceActivity.Activities>
                  <p:IfElse ValueDate="{x:Null}" ValueDate_DisplayArg="{x:Null}" ValueDate_Item="{x:Null}" ValueDate_ItemProp="{x:Null}" ValueNum="{x:Null}" ValueNum_DisplayArg="{x:Null}" ValueNum_Item="{x:Null}" ValueNum_ItemProp="{x:Null}" ValueString_Item="{x:Null}" ValueString_ItemProp="{x:Null}" VariableDate="{x:Null}" VariableDate_DisplayArg="{x:Null}" VariableDate_Item="{x:Null}" VariableDate_ItemProp="{x:Null}" VariableNum="{x:Null}" VariableNum_DisplayArg="{x:Null}" VariableNum_Item="{x:Null}" VariableNum_ItemProp="{x:Null}" VariableString_Item="{x:Null}" VariableString_ItemProp="{x:Null}" Condition="equals" DisplayName="If/Else" sap:VirtualizedContainerService.HintSize="870,500" Moniker="f9ea6797-d777-483d-887f-f2676b52a222" Result="[IfElse_Result_7]" ScriptDirectory="goog" Type="string" TypeName="IfElse" ValueString="[RunScript_StoredName_1]" ValueString_DisplayArg="ChecksifClassNameChangeExistsinWMIandoutputStoredNameifExists.StoredName" VariableString="[GetEnvironmentVariable_Value_0]" VariableString_DisplayArg="GetsthelocalComputerName.Value" m_bTextLinkChange="False">
                    <p:IfElse.ElseOption>
                      <ActivityAction>
                        <p:SequenceActivity DisplayName="Name is changed" sap:VirtualizedContainerService.HintSize="418,340" Name="SequenceActivity">
                          <p:SequenceActivity.Activities>
                            <p:RunScript DisplayName="Update the WMI NameChange class with the TRUE field" sap:VirtualizedContainerService.HintSize="398,218" Moniker="c6473b8a-3499-461f-85fe-ec3bc4ae689c" Result="[RunScript_Result_13]" ScriptDirectory="goog" TypeName="RunScript" genArgEvent="b94e146c-1154-4340-bb6a-c18c7acb3b88" m_bTextLinkChange="False" script="JFB1c2hEYXRhVG9XTUkgPSAoW3dtaWNsYXNzXSJyb290XGNpbXYyXE5jZW50cmFsOk5hbWVDaGFuZ2UiKS5DcmVhdGVJbnN0YW5jZSgpDQokUHVzaERhdGFUb1dNSS5JbmRleCA9IDENCiRQdXNoRGF0YVRvV01JLlN0b3JlZE5hbWUgPSAiJCVpZCVTY3JpcHRDb21wdXRlck5hbWVJc0NoYW5nZWQlaWQlIg0KJFB1c2hEYXRhVG9XTUkuTmFtZUhhc0NoYW5nZWQgPSAxDQokUHVzaERhdGFUb1dNSS5QdXQoKQ==">
                              <p:RunScript.InArgs>
                                <p:InArg ItemProp="{x:Null}" x:Key="ScriptComputerNameIsChanged" ArgType="string" DisplayArg="GetsthelocalComputerName.Value" DisplayName="ScriptComputerNameIsChanged" Name="ScriptComputerNameIsChanged" isRequired="True" isRequiredDisplay="Yes">
                                  <p:InArg.Arg>
                                    <InArgument x:TypeArguments="x:String">[GetEnvironmentVariable_Value_0]</InArgument>
                                  </p:InArg.Arg>
                                  <p:InArg.Item>
                                    <InArgument x:TypeArguments="x:Object" />
                                  </p:InArg.Item>
                                </p:InArg>
                              </p:RunScript.InArgs>
                              <p:RunScript.OutArgs>
                                <scg:Dictionary x:TypeArguments="x:String, p:OutArg" />
                              </p:RunScript.OutArgs>
                            </p:RunScript>
                          </p:SequenceActivity.Activities>
                          <p:SequenceActivity.Variables>
                            <Variable x:TypeArguments="x:Double" Name="RunScript_Result_13" />
                          </p:SequenceActivity.Variables>
                        </p:SequenceActivity>
                      </ActivityAction>
                    </p:IfElse.ElseOption>
                    <p:IfElse.IfOption>
                      <ActivityAction>
                        <p:SequenceActivity DisplayName="Name is not changed" sap:VirtualizedContainerService.HintSize="418,340" Name="SequenceActivity">
                          <p:SequenceActivity.Activities>
                            <p:RunScript DisplayName="Update the WMI NameChange class with the TRUE field " sap:VirtualizedContainerService.HintSize="398,218" Moniker="51f10271-9b74-4402-8d33-733ee7a9848d" Result="[RunScript_Result_12]" ScriptDirectory="goog" TypeName="RunScript" genArgEvent="aa3c2fd5-80a7-4638-b344-8fb12f340637" m_bTextLinkChange="False" script="JFB1c2hEYXRhVG9XTUkgPSAoW3dtaWNsYXNzXSJyb290XGNpbXYyXE5jZW50cmFsOk5hbWVDaGFuZ2UiKS5DcmVhdGVJbnN0YW5jZSgpDQokUHVzaERhdGFUb1dNSS5JbmRleCA9IDENCiRQdXNoRGF0YVRvV01JLlN0b3JlZE5hbWUgPSAiJCVpZCVTY3JpcHROb3RDaGFuZ2VkQ29tcHV0ZXJOYW1lJWlkJSINCiRQdXNoRGF0YVRvV01JLk5hbWVIYXNDaGFuZ2VkID0gMA0KJFB1c2hEYXRhVG9XTUkuUHV0KCk=">
                              <p:RunScript.InArgs>
                                <p:InArg ItemProp="{x:Null}" x:Key="ScriptNotChangedComputerName" ArgType="string" DisplayArg="GetsthelocalComputerName.Value" DisplayName="ScriptNotChangedComputerName" Name="ScriptNotChangedComputerName" isRequired="True" isRequiredDisplay="Yes">
                                  <p:InArg.Arg>
                                    <InArgument x:TypeArguments="x:String">[GetEnvironmentVariable_Value_0]</InArgument>
                                  </p:InArg.Arg>
                                  <p:InArg.Item>
                                    <InArgument x:TypeArguments="x:Object" />
                                  </p:InArg.Item>
                                </p:InArg>
                              </p:RunScript.InArgs>
                              <p:RunScript.OutArgs>
                                <scg:Dictionary x:TypeArguments="x:String, p:OutArg" />
                              </p:RunScript.OutArgs>
                            </p:RunScript>
                          </p:SequenceActivity.Activities>
                          <p:SequenceActivity.Variables>
                            <Variable x:TypeArguments="x:Double" Name="RunScript_Result_12" />
                          </p:SequenceActivity.Variables>
                        </p:SequenceActivity>
                      </ActivityAction>
                    </p:IfElse.IfOption>
                  </p:IfElse>
                </p:SequenceActivity.Activities>
                <p:SequenceActivity.Variables>
                  <Variable x:TypeArguments="x:Double" Name="IfElse_Result_7" />
                </p:SequenceActivity.Variables>
              </p:SequenceActivity>
            </ActivityAction>
          </p:IfObject.IfOption>
        </p:IfObject>
        <p:Log Message_Item="{x:Null}" Message_ItemProp="{x:Null}" DisplayName="ComputerName" sap:VirtualizedContainerService.HintSize="914,57" LogMessage="[Log_LogMessage_14]" Message="[GetEnvironmentVariable_Value_0]" Message_DisplayArg="GetsthelocalComputerName.Value" Moniker="57fc3cd3-291b-4ceb-97b1-1362dc8504f7" Result="[Log_Result_15]" ScriptDirectory="goog" TypeName="Log" m_bTextLinkChange="False" />
        <p:Log Message_Item="{x:Null}" Message_ItemProp="{x:Null}" DisplayName="StoredName" sap:VirtualizedContainerService.HintSize="914,57" LogMessage="[Log_LogMessage_16]" Message="[RunScript_StoredName_1]" Message_DisplayArg="ChecksifClassNameChangeExistsinWMIandoutputStoredNameifExists.StoredName" Moniker="b43d2816-f522-410b-8438-c6e2a16caa33" Result="[Log_Result_17]" ScriptDirectory="goog" TypeName="Log" m_bTextLinkChange="False" />
      </p:PolicySequence.Activities>
      <p:PolicySequence.Variables>
        <Variable x:TypeArguments="x:String" Name="GetEnvironmentVariable_Value_0" />
        <Variable x:TypeArguments="x:Double" Name="GetEnvironmentVariable_Result_1" />
        <Variable x:TypeArguments="x:Double" Name="RunScript_Result_2" />
        <Variable x:TypeArguments="x:Double" Name="RunScript_Result_0" />
        <Variable x:TypeArguments="x:String" Name="RunScript_StoredName_1" />
        <Variable x:TypeArguments="x:Double" Name="IfObject_Result_2" />
        <Variable x:TypeArguments="x:Double" Name="IfObject_Result_6" />
        <Variable x:TypeArguments="x:String" Name="Log_LogMessage_14" />
        <Variable x:TypeArguments="x:Double" Name="Log_Result_15" />
        <Variable x:TypeArguments="x:String" Name="Log_LogMessage_16" />
        <Variable x:TypeArguments="x:Double" Name="Log_Result_17" />
      </p:PolicySequence.Variables>
    </p:PolicySequence>
  </Activity>
</Policy>
```

```shell VBS
' NameChange.vbs
' Designed to be run once a day.  Grabs the name of the device it runs on and stores it in WMI.  Next time it runs
' it looks at the name again and compares it to the stored version.  If the names differ, the device has changed name.
' It then writes a value into WMI which the "Name Change" service picks up on in N-central
'
' RECOMMENDED:  If you alert on this service it is recommended that you turn OFF the option in the notification to
'               "Notify on return to normal" and give the notification a 0 minute delay.  The service will transition
'               to a fail state when the name change is detected but will return to a normal state the next time the
'               script runs.

' By Tim Wiser, Orchid IT (July 2012)
' Uses code lifted from Chris Reid's AVstatus.vbs as well as other sources online - credits given where due



option explicit

dim wbemCimtypeString, wbemCimtypeBoolean, wbemCimtypeUint32
dim strComputer, strWMINamespace, strNamespace, strWMIClassWithQuotes, strWMIClassNoQuotes, strStoredComputerName, strComputerName
dim ParentWMINamespace, objWMISvc, objItem, objNamespace, objWMIOrchid, WMINamespace, objWMIService, objClassCreator, objWMI, objData, objInstance, objNewNamespace
dim colItems, colNamespaces, colClasses, objClasses, objClass, objGetClass, objNewInstance

strComputer = "."
strWMINamespace = "ncentral"
strNamespace = "root\cimv2\ncentral"
strWMIClassWithQuotes = chr(34) & "NameChange" & chr(34)
strWMIClassNoQuotes = "NameChange"
wbemCimtypeString = 8
wbemCimtypeUint32 = 19
wbemCimtypeBoolean = 11

Set ParentWMINamespace = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set objWMISvc = GetObject( "winmgmts:\\.\root\cimv2" )
Set colItems = objWMISvc.ExecQuery( "Select * from Win32_ComputerSystem", , 48 )
For Each objItem in colItems
    strComputerName = objItem.Name
Next

wscript.echo "Current device name is " & strComputerName

' Check to see if the namespace exists.  If not, create it
If WMINamespaceExists(ParentWMINamespace, strWMINamespace) then
	wscript.echo "The namespace already exists"
else
	wscript.echo "The namespace does not exist - Creating it now"
	CreateWMINamespace
end if


' Check to see if the class exists.  If not, create it
If WMIClassExists(strComputer, strWMIClassWithQuotes) Then
	wscript.echo "The class exists"
else
	wscript.echo "The class doesn't exist - creating it now"
	CreateWMIClass
	PopulateWMIClass
end if


' OK, so if we get this far we have a namespace and a class to read from.
' Now we need to read the stored name for the device from WMI and compare it with the live name
Set objWMISvc = GetObject( "winmgmts:\\.\root\cimv2\ncentral" )
Set colItems = objWMISvc.ExecQuery( "Select * from NameChange WHERE index = 1", , 48 )
For Each objItem in colItems
    strStoredComputerName = objItem.StoredName
	wscript.echo "The name stored in WMI is " & strStoredComputerName
Next

if strStoredComputerName <> strComputerName then
	wscript.echo "The computer name has changed!"
	Set objWMI = GetObject("winmgmts:root\cimv2\ncentral") 
	Set objData = objWMI.Get("NameChange") 
	Set objInstance = objData.SpawnInstance_ 
		objInstance.Index = 1
		objInstance.NameHasChanged = True
		objInstance.StoredName = strComputerName
		objInstance.Put_()
else
	wscript.echo "The names are the same"
	Set objWMI = GetObject("winmgmts:root\cimv2\ncentral") 
	Set objData = objWMI.Get("NameChange") 
	Set objInstance = objData.SpawnInstance_ 
		objInstance.Index = 1
		objInstance.NameHasChanged = False
		objInstance.StoredName = strComputerName
		objInstance.Put_()
end if







' *****************************  
' Sub: CreateWMINamespace
' *****************************
Sub CreateWMINamespace
    Set objItem = ParentWMINamespace.Get("__Namespace")
    Set objNewNamespace = objItem.SpawnInstance_    
    objNewNamespace.Name = strWMINamespace
    objNewNamespace.Put_
End Sub





' *****************************  
' Sub: CreateWMIClass
' *****************************
Sub CreateWMIClass
    Set objWMIService = GetObject("Winmgmts:root\cimv2\" & strWMINamespace)
    Set objClassCreator = objWMIService.Get() 'Load the Namespace           
    'Define the Properties of the WMI Class
    objClassCreator.Path_.Class = "" & strWMIClassNoQuotes
    
    objClassCreator.Properties_.add "StoredName", wbemCimtypeString
    objClassCreator.Properties_.add "NameHasChanged", wbemCimtypeBoolean
	objClassCreator.Properties_.add "Index", wbemCimtypeUint32
	
	objClassCreator.Properties_("Index").Qualifiers_.add "key", true
                           
    ' Write the new class
    objClassCreator.Put_

End Sub
    
    
' *****************************  
' Function: WMINamespaceExists
' Thanks to http://www.cruto.com/resources/vbscript/vbscript-examples/misc/wmi/List-All-WMI-Namespaces.asp for this code 
' *****************************
Function WMINamespaceExists(ParentWMINamespace,WMINamespace)
                WMINamespaceExists = vbFalse
                Set colNamespaces = ParentWMINamespace.InstancesOf("__Namespace")
                For Each objNamespace In colNamespaces
                      If instr(objNamespace.Path_.Path,WMINamespace) Then
                            WMINamespaceExists = vbTrue                        
					  End if
                Next
                Set colNamespaces = Nothing
End Function


  


' *****************************  
' Function: WMIClassExists
' Thanks to http://gallery.technet.microsoft.com/ScriptCenter/en-us/a1b23364-34cb-4b2c-9629-0770c1d22ff0 for this code 
' *****************************
Function WMIClassExists(strComputer, strWMIClassWithQuotes)
                WMIClassExists = vbFalse
                Set WMINamespace = GetObject("winmgmts:\\" & strComputer & "\root\cimv2\" & strWMINamespace)
                Set colClasses = WMINamespace.SubclassesOf()
                For Each objClass In colClasses
                      If instr(objClass.Path_.Path,strWMIClassNoQuotes) Then
                            WMIClassExists = vbTrue
                      End if
                Next
                Set colClasses = Nothing
End Function  
  
     

    
' *****************************  
' Sub: PopulateWMIClass
' *****************************
Sub PopulateWMIClass    
    'Create an instance of the WMI class using SpawnInstance_
    Set WMINamespace = GetObject("winmgmts:\\" & strComputer & "\root\cimv2\" & strWMINamespace)
    Set objGetClass = WMINamespace.Get(strWMIClassNoQuotes)
    Set objNewInstance = objGetClass.SpawnInstance_
    objNewInstance.StoredName = strComputerName
	objNewInstance.Index = 1
    objNewInstance.NameHasChanged = False
        
    ' Write the instance into the WMI repository
    objNewInstance.Put_()
End Sub

```

```json Response Example
{"success":true}
```

# Information

<!-- powershell@1-259 -->
<!-- shell@1-184 -->

This service is intended to provide an alert when a device (server, workstation or laptop) is renamed by the end user.  As N-central does not currently have the ability to automatically update the Name field on a device (only Discovered Name) this can result in the device names shown in All Devices gradually becoming more and more inaccurate.


Implementation: Schedule the AMP (for N-central v9 onwards) or VBS (any version of N-central) to run on devices every day or every few hours.  Once the script runs it will pick up the current name of the device and store it.  The next time the script runs it compares the current name with the stored name and if they differ it will cause the "Name Change" service in N-central to transition to a fail state.

Recommendation: We recommend that you configure a notification against this service with a 0 minute delay and the option to "Notify on return to Normal" option DISABLED.  Once the service is in a fail state it will return to normal the next time the script runs.

# Initialization of Variables

<!-- powershell@1 -->
<!-- shell@17-32 -->

Set up constants and variables that will be used throughout the script.

# Get Current Computer Name

<!-- powershell@69 -->
<!-- shell@33-42 -->

Retrieve the name of the computer running the script.

# Check for WMI Namespace

<!-- shell@43-50 -->

Check if the specified WMI namespace exists; if not, create it.

# Check for WMI Class

<!-- shell@52-60 -->

Verify if the WMI class for name changes exists; create it if it doesn’t.

# Retrieve Stored Computer Name

<!-- shell@62-70 -->

Get the previously stored computer name from WMI for comparison.

# Compare Current and Stored Names

<!-- shell@71,72,80,81,82 -->

Check if the current device name differs from the stored name.

# Update WMI with New Name

<!-- shell@73-80,82-90 -->

If the name has changed, update the WMI class instance with the new name.