update
This commit is contained in:
@@ -0,0 +1,492 @@
|
||||
# required for basic auth
|
||||
$Url = "https://northdakota.service-now.com"
|
||||
$HeaderAuth = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $SNowVMCred.UserName, $SnowVMCred.GetNetworkCredential().Password)))
|
||||
$SNOWSessionHeader = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
|
||||
$SNOWSessionHeader.Add('Authorization', ('Basic {0}' -f $HeaderAuth))
|
||||
$SNOWSessionHeader.Add('Accept', 'application/json')
|
||||
$Type = "application/json"
|
||||
|
||||
# open incident in webgui, sysid is in the url
|
||||
# example: https://northdakotatest.service-now.com/nav_to.do?uri=%2Fincident.do%3Fsys_id%3Db6e3f5d91b9a29d0128ec806604bcb9a%26sysparm_record_target%3Dtask%26sysparm_record_row%3D7%26sysparm_record_rows%3D10%26sysparm_record_list%3Dactive%3Dtrue%5Eassigned_to%3Djavascript:gs.user_id()%5EORDERBYDESCnumber
|
||||
# sys_id=guid
|
||||
Invoke-RestMethod -Method GET -Uri ($Url + "/api/now/table/incident/b6e3f5d91b9a29d0128ec806604bcb9a") -Credential $SNowVMCred -Headers $SnowSessionHeader -ContentType $Type -ov x
|
||||
|
||||
# 10000 results
|
||||
#Invoke-RestMethod -Method GET -Uri ($Url + "api/now/table/incident") -Credential $SNowVMCred -Headers $SnowSessionHeader -ContentType $Type -ov y
|
||||
|
||||
#### better formatting
|
||||
$InvokeRestMethodParams = @{
|
||||
Method = 'Get';
|
||||
Uri = ($Url + "/api/now/table/sc_req_item");
|
||||
ContentType = $Type;
|
||||
Headers = $SNOWSessionHeader;
|
||||
Body = @{
|
||||
sysparm_query = 'number=RITM0282695';
|
||||
sysparm_limit = 1;
|
||||
sysparm_display_value = 'true'; #### show human readable values, not just sysids
|
||||
sysparm_fields = 'request,cat_item';
|
||||
}
|
||||
|
||||
}
|
||||
(Invoke-RestMethod @InvokeRestMethodParams -ov c).result
|
||||
|
||||
|
||||
# known tables below
|
||||
# incident INC########
|
||||
Invoke-RestMethod -Method GET -Uri ($Url + "/api/now/table/incident?sysparm_query=number=INC0437213&sysparm_limit=1") -Credential $SNowVMCred -Headers $SnowSessionHeader -ContentType $Type -ov x
|
||||
Invoke-RestMethod -Method GET -Uri ($Url + "/api/now/table/incident?sysparm_query=number=INC0437213&sysparm_limit=1&sysparm_display_value=true") -Credential $SNowVMCred -Headers $SnowSessionHeader -ContentType $Type -ov y
|
||||
|
||||
# change_request CHG########
|
||||
Invoke-RestMethod -Method GET -Uri ($Url + "api/now/table/change_request?sysparm_query=number=CHG0089327&sysparm_limit=1") -Credential $SNowVMCred -Headers $SnowSessionHeader -ContentType $Type
|
||||
|
||||
#sc_request REQ########
|
||||
Invoke-RestMethod -Method GET -Uri ($Url + "api/now/table/sc_request?sysparm_query=number=REQ0129027&sysparm_limit=1") -Credential $SNowVMCred -Headers $SnowSessionHeader -ContentType $Type
|
||||
|
||||
#sc_req_item RITM########
|
||||
Invoke-RestMethod -Method GET -Uri ($Url + "api/now/table/sc_req_item?sysparm_query=number=RITM0134884&sysparm_limit=1") -Credential $SNowVMCred -Headers $SnowSessionHeader -ContentType $Type
|
||||
|
||||
#sc_task SCTASK#######
|
||||
|
||||
#sys_user
|
||||
Invoke-RestMethod -Method GET -Uri ($Url + "api/now/table/sys_user?sysparm_query=email=zmeier@nd.gov&sysparm_limit=1") -Credential $SNowVMCred -Headers $SnowSessionHeader -ContentType $Type -ov x
|
||||
|
||||
#sys_user_group
|
||||
Invoke-RestMethod -Method GET -Uri ($Url + "api/now/table/sys_user_group?name=NDIT-Computer Systems&sysparm_limit=1") -Credential $SNowVMCred -Headers $SnowSessionHeader -ContentType $Type -ov x
|
||||
|
||||
# cmdb_ci_ip_network
|
||||
Invoke-RestMethod -Method GET -Uri ($Url + "api/now/table/cmdb_ci_ip_network") -Credential $SNowVMCred -Headers $SnowSessionHeader -ContentType $Type -ov x
|
||||
|
||||
# appname / cmdb_ci_service_auto_list
|
||||
Invoke-RestMethod -Method GET -Uri ($Url + "api/now/table/cmdb_ci_service_auto") -Credential $SNowVMCred -Headers $SnowSessionHeader -ContentType $Type -ov x
|
||||
|
||||
https://northdakota.service-now.com/cmdb_ci_service_auto_list.do?sysparm_target=ni.VEacf3763e475c7514baa37834846d433c&sysparm_target_value=&sysparm_reference_value=&sysparm_nameofstack=reflist&sysparm_clear_stack=true&sysparm_element=not&sysparm_reference=cmdb_ci_service_auto&sysparm_view=sys_ref_list&sysparm_form_view=default&sysparm_additional_qual=&sysparm_parent_id=a3feaecb47d0b914baa37834846d4381&sysparm_domain_restore=false
|
||||
|
||||
# all tables
|
||||
$a = Invoke-RestMethod -Method GET -Uri ($Url + "api/now/table/sys_db_object") -Credential $SNowVMCred -Headers $SnowSessionHeader -ContentType $Type
|
||||
|
||||
|
||||
Invoke-RestMethod -Method GET -Uri ($Url + "api/now/table/sc_ic_category_request?&sysparm_limit=100") -Credential $SNowVMCred -Headers $SnowSessionHeader -ContentType $Type -ov c
|
||||
|
||||
# searching incidents
|
||||
?sysparm_query=number=INC0437213
|
||||
sysparm_query%3Dshort_descriptionLIKEhardware
|
||||
Invoke-RestMethod -Method GET -Uri ($Url + "api/now/table/incident&sysparm_limit=3?sysparm_query=short_descriptionLIKEhardware") -Credential $SNowVMCred -Headers $SnowSessionHeader -ContentType $Type -ov x
|
||||
|
||||
|
||||
# cmdb_ci_vmware_instance
|
||||
Invoke-RestMethod -Method GET -Uri ($Url + "api/now/table/cmdb_ci_vmware_instance") -Credential $SNowVMCred -Headers $SnowSessionHeader -ContentType $Type -ov x
|
||||
|
||||
# create records
|
||||
# incident
|
||||
[PSCustomObject]$NewRecord = @{
|
||||
short_description = "failed machine";
|
||||
caller_id = "Zachary L Meier";
|
||||
# and others, get record to view
|
||||
}
|
||||
$InvokeRestMethodParams = @{
|
||||
Method = 'Post';
|
||||
Uri = ($Url + "api/now/table/incident");
|
||||
Body = $NewRecord | ConvertTo-Json;
|
||||
Headers = $SnowSessionHeader;
|
||||
ContentType = "application/json"
|
||||
}
|
||||
|
||||
Invoke-RestMethod @InvokeRestMethodParams
|
||||
|
||||
|
||||
|
||||
# update records
|
||||
# incident, sys_id required
|
||||
# incident state 1 = new, 2 = in progress, 3 = on hold
|
||||
[PSCustomObject]$SetRecord = @{
|
||||
short_description = "lots of failed hardware";
|
||||
description = "omg send help"
|
||||
caller_id = "Zachary L Meier";
|
||||
state = 3 # on hold
|
||||
|
||||
# and others, get record to view remaining options
|
||||
}
|
||||
$InvokeRestMethodParams = @{
|
||||
Method = 'Put';
|
||||
Uri = ($Url + "api/now/table/incident/fec7a7a91ba761504e2afeee034bcba8");
|
||||
Body = $SetRecord | ConvertTo-Json;
|
||||
Headers = $SnowSessionHeader;
|
||||
ContentType = "application/json"
|
||||
}
|
||||
|
||||
Invoke-RestMethod @InvokeRestMethodParams
|
||||
|
||||
|
||||
# custom fields lookup
|
||||
$RitmNum = 'RITM0157839'
|
||||
$RitmNum = 'RITM0260967'
|
||||
$Ritm = Get-ITDServiceNowRecord -ItemType 'Request Item' -Number $RitmNum
|
||||
|
||||
$params = @{
|
||||
Method = 'Get';
|
||||
Uri = ('https://northdakota.service-now.com/api/now/table/sc_item_option_mtom?request_item=' + $Ritm.Sys_id.value + '&sysparm_limit=1000');
|
||||
Headers = $SNOWSessionHeader;
|
||||
ContentType = "application/json"
|
||||
}
|
||||
$CustomFieldsLookup = (Invoke-RestMethod @params).result
|
||||
|
||||
# get each custom field individually
|
||||
$sc_item_options = ForEach ($CustomField in $CustomFieldsLookup) {
|
||||
#$scitemsysid = $sc_item_option.sc_item_option.value
|
||||
$params = @{
|
||||
Method = 'Get';
|
||||
Uri = ("https://northdakota.service-now.com/api/now/table/sc_item_option?sys_id=" + $CustomField.sc_item_option.value ); #+ "&sysparm_limit=100"
|
||||
Headers = $SNOWSessionHeader;
|
||||
ContentType = "application/json"
|
||||
}
|
||||
(Invoke-RestMethod @params).result
|
||||
}
|
||||
|
||||
$MyArrayList = [System.Collections.ArrayList]@()
|
||||
ForEach ($sc_item_option in $sc_item_options) {
|
||||
$params = @{
|
||||
Method = 'Get';
|
||||
Uri = ("https://northdakota.service-now.com/api/now/table/item_option_new?sys_id=" + $sc_item_option.item_option_new.value);
|
||||
Headers = $SNOWSessionHeader;
|
||||
ContentType = "application/json"
|
||||
}
|
||||
$vars = (Invoke-RestMethod @params).result
|
||||
$obj = [PSCustomObject]@{
|
||||
#sc_item_option_sysid = $sc_item_option.sys_id
|
||||
#item_option_new_sysid = $vars.sys_id
|
||||
name = $vars.name
|
||||
question_text = $vars.question_text
|
||||
value = $sc_item_option.value
|
||||
type = $vars.type
|
||||
# YES_NO = 1; MULTI_LINE_TEXT = 2; MULTIPLE_CHOICE = 3; NUMERIC_SCALE = 4; SELECT_BOX = 5; SINGLE_LINE_TEXT = 6; CHECKBOX = 7; REFERENCE = 8; DATE = 9; DATE_TIME = 10; LABEL = 11; BREAK = 12; MACRO = 14; UI_PAGE = 15; WIDE_SINGLE_LINE_TEXT = 16; MACRO_WITH_LABEL = 17; LOOKUP_SELECT_BOX = 18; CONTAINER_START = 19; CONTAINER_END = 20; LIST_COLLECTOR = 21; LOOKUP_MULTIPLE_CHOICE = 22; HTML = 23; SPLIT = 24; MASKED = 25;
|
||||
}
|
||||
$null = $MyArrayList.Add($obj)
|
||||
}
|
||||
#$Ritm | Add-Member -MemberType NoteProperty -Name CustomFields -Value $MyArrayList
|
||||
|
||||
|
||||
#######################################
|
||||
$Ritm | Add-Member @{
|
||||
'CustomVariable' = [pscustomobject]@{}
|
||||
}
|
||||
|
||||
$InvokeRestMethodParams = @{
|
||||
Method = 'Get';
|
||||
Uri = ($Url + "/api/now/table/sc_item_option_mtom");
|
||||
Body = @{
|
||||
request_item = $Ritm.sys_id;
|
||||
sysparm_fields = (@('sc_item_option.item_option_new.name',
|
||||
'sc_item_option.value',
|
||||
'sc_item_option.item_option_new.type',
|
||||
'sc_item_option.item_option_new.question_text',
|
||||
'sc_item_option.item_option_new.reference') -join ',');
|
||||
sysparm_query = "request_item=dd02ed854744bd18baa37834846d43fb^sc_item_option.item_option_new.typeIN1,2,3,4,5,6,7,8,9,10,16,18,21,22,26"
|
||||
|
||||
};
|
||||
ContentType = 'application/json';
|
||||
Headers = $SNOWSessionHeader;
|
||||
}
|
||||
|
||||
$customVars = (Invoke-RestMethod @InvokeRestMethodParams).result #-ov c
|
||||
|
||||
ForEach ($var in $customVars) {
|
||||
$newVar = [pscustomobject] @{
|
||||
Value = $var.'sc_item_option.value'
|
||||
DisplayName = $var.'sc_item_option.item_option_new.question_text'
|
||||
Type = $var.'sc_item_option.item_option_new.type'
|
||||
}
|
||||
|
||||
# show the underlying value if the option is a reference type
|
||||
<#if ($newVar.Type -eq 'Reference' ) {
|
||||
$newVar.Value = (Get-ServiceNowRecord -Table $var.'sc_item_option.item_option_new.reference' -ID $var.'sc_item_option.value' -Property name -AsValue -ServiceNowSession $ServiceNowSession)
|
||||
}#>
|
||||
$RITM.CustomVariable | Add-Member @{ $var.'sc_item_option.item_option_new.name' = $newVar }
|
||||
}
|
||||
|
||||
|
||||
|
||||
request_item=dd02ed854744bd18baa37834846d43fb^sc_item_option.item_option_new.typeIN1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 16, 18, 21, 22, 26
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#################################################################
|
||||
|
||||
|
||||
41e3290a1b1aed14128ec806604bcb50
|
||||
$params = @{
|
||||
Method = 'Get';
|
||||
Uri = ("https://northdakotatest.service-now.com/api/now/table/sc_item_option?sys_id=" + '41e3290a1b1aed14128ec806604bcb50' ); #+ "&sysparm_limit=100"
|
||||
Headers = $SNOWSessionHeader;
|
||||
ContentType = "application/json"
|
||||
}
|
||||
(Invoke-RestMethod @params).result
|
||||
|
||||
|
||||
#get standard change template
|
||||
$AllChangeTemplateStandard = Invoke-RestMethod -Method Get -Uri ($Url + "api/sn_chg_rest/change/standard/template?sysparm_query=active=true") -Credential $SNowVMCred -Headers $SnowSessionHeader -ContentType $Type
|
||||
$AllChangeTemplateStandard = Invoke-RestMethod -Method Get -Uri ($Url + "api/sn_chg_rest/change/standard/template?sysparm_query=active=true^name=$Name") -Headers $SnowSessionHeader -ContentType $Type
|
||||
$SearchResult = $AllChangeTemplateStandard.result | Where-Object { $_.Name.display_value -eq $StdChangeTemplateName }
|
||||
|
||||
|
||||
# update record
|
||||
$Number = 'CHG0098990'
|
||||
Invoke-RestMethod -Method GET -Uri ($Url + "api/now/table/change_request/41b66f1e1b5af5104e2afeee034bcb97") -Credential $SNowVMCred -Headers $SnowSessionHeader -ContentType $Type -ov x
|
||||
$Values = @{
|
||||
short_description = 'this is a new description'
|
||||
}
|
||||
$Body = $Values | ConvertTo-Json
|
||||
Invoke-RestMethod -Method Patch -Uri ($Url + "api/now/table/change_request/41b66f1e1b5af5104e2afeee034bcb97") -Credential $SNowVMCred -Headers $SnowSessionHeader -ContentType $Type -ov x -Body $body
|
||||
|
||||
# date/time current time
|
||||
[DateTime]::UtcNow.ToString('yyyy-MM-dd HH:mm:ss');
|
||||
(Get-Date -AsUTC).ToString('yyyy-MM-dd HH:mm:ss')
|
||||
|
||||
|
||||
|
||||
|
||||
# submit service catalog request
|
||||
$SysId = 'a490f76adbc0e8901b47105f68961941' #generic service request test
|
||||
$CommentsFieldExample = @"
|
||||
Create nd.gov Active Directory service account for use by ITD System Administrators:
|
||||
|
||||
{
|
||||
"PasswordstateTitle": "itdzmtest99.nd.gov",
|
||||
"PasswordstateList": "CSRC",
|
||||
"SamAccountName": "svczmtest99",
|
||||
"Description": "description for things"
|
||||
}
|
||||
"@
|
||||
|
||||
# submit catalog request, the powershell way
|
||||
$BodyJson | ConvertFrom-Json
|
||||
|
||||
$BodyObj = [PSCustomObject]@{
|
||||
sysparm_quantity = "1";
|
||||
variables = [PSCustomObject]@{
|
||||
v_user_phone = "(701) 328-4171";
|
||||
v_requested_by = "206d9e091b8898102653997fbd4bcbd4";
|
||||
v_approval_department_code = "112.0";
|
||||
requester_information = "true";
|
||||
v_container_requested_for = "true";
|
||||
v_manager = "1c1d16451b8898102653997fbd4bcb3b";
|
||||
v_requested_for = "206d9e091b8898102653997fbd4bcbd4";
|
||||
v_type = "Server Systems/Hosting";
|
||||
additional_comments = "comments";
|
||||
v_user_in_servicenow = "Yes";
|
||||
v_approval_division = "f40758231b321450bba0113fad4bcb2d";
|
||||
v_container_requested_by = "true";
|
||||
approval_information = "true";
|
||||
v_approval_division_code = "32";
|
||||
request_commnets = "true";
|
||||
v_user_email = "zmeier@nd.gov";
|
||||
request_information = "true";
|
||||
v_alt_contact = "";
|
||||
v_approval_department = "f3c65cef1bfed050bba0113fad4bcb1d";
|
||||
v_approval_charge_code = "";
|
||||
}
|
||||
}
|
||||
$NewJson = $BodyObj | ConvertTo-Json
|
||||
$InvokeRestMethodParams = @{
|
||||
Method = 'Post';
|
||||
Uri = "https://northdakotatest.service-now.com/api/sn_sc/servicecatalog/items/a490f76adbc0e8901b47105f68961941/order_now";
|
||||
Credential = $SNowVMCred;
|
||||
Headers = $SNOWSessionHeader;
|
||||
ContentType = $Type;
|
||||
Body = $NewJson #'{"sysparm_quantity":"1","variables":{"v_user_phone":"(701) 328-4171","v_requested_by":"206d9e091b8898102653997fbd4bcbd4","v_approval_department_code":"112.0","requester_information":"true","v_container_requested_for":"true","v_manager":"1c1d16451b8898102653997fbd4bcb3b","v_requested_for":"206d9e091b8898102653997fbd4bcbd4","v_type":"Server Systems/Hosting","additional_comments":"moar comments!!2!","v_user_in_servicenow":"Yes","v_approval_division":"f40758231b321450bba0113fad4bcb2d","v_container_requested_by":"true","approval_information":"true","v_approval_division_code":"32","request_commnets":"true","v_user_email":"zmeier@nd.gov","request_information":"true","v_alt_contact":"","v_approval_department":"f3c65cef1bfed050bba0113fad4bcb1d","v_approval_charge_code":""},"sysparm_item_guid":"05adfdcf1b96bd104e2afeee034bcb1d","get_portal_messages":"true","sysparm_no_validation":"true","engagement_channel":"sp","referrer":null}'
|
||||
}
|
||||
Invoke-RestMethod @InvokeRestMethodParams -OutVariable e
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# new vm form and custom variables
|
||||
$RitmNum = 'RITM0233555'
|
||||
$Ritm = Get-ITDServiceNowRecord -ItemType 'Request Item' -Number $RitmNum
|
||||
|
||||
$params = @{
|
||||
Method = 'Get';
|
||||
Uri = ('https://northdakotadev.service-now.com/api/now/table/sc_item_option_mtom?request_item=' + $Ritm.Sys_id + '&sysparm_limit=1000');
|
||||
Headers = $SNOWSessionHeader;
|
||||
ContentType = "application/json"
|
||||
}
|
||||
$CustomFieldsLookup = (Invoke-RestMethod @params).result
|
||||
|
||||
# get each custom field individually
|
||||
$sc_item_options = ForEach ($CustomField in $CustomFieldsLookup) {
|
||||
#$scitemsysid = $sc_item_option.sc_item_option.value
|
||||
$params = @{
|
||||
Method = 'Get';
|
||||
Uri = ("https://northdakotadev.service-now.com/api/now/table/sc_item_option?sys_id=" + $CustomField.sc_item_option.value ); #+ "&sysparm_limit=100"
|
||||
Headers = $SNOWSessionHeader;
|
||||
ContentType = "application/json"
|
||||
}
|
||||
(Invoke-RestMethod @params).result
|
||||
}
|
||||
|
||||
$MyArrayList = [System.Collections.ArrayList]@()
|
||||
ForEach ($sc_item_option in $sc_item_options) {
|
||||
$params = @{
|
||||
Method = 'Get';
|
||||
Uri = ("https://northdakotadev.service-now.com/api/now/table/item_option_new?sys_id=" + $sc_item_option.item_option_new.value);
|
||||
Headers = $SNOWSessionHeader;
|
||||
ContentType = "application/json"
|
||||
}
|
||||
$vars = (Invoke-RestMethod @params).result
|
||||
$obj = [PSCustomObject]@{
|
||||
#sc_item_option_sysid = $sc_item_option.sys_id
|
||||
#item_option_new_sysid = $vars.sys_id
|
||||
name = $vars.name
|
||||
question_text = $vars.question_text
|
||||
value = $sc_item_option.value
|
||||
type = $vars.type
|
||||
# YES_NO = 1; MULTI_LINE_TEXT = 2; MULTIPLE_CHOICE = 3; NUMERIC_SCALE = 4; SELECT_BOX = 5; SINGLE_LINE_TEXT = 6; CHECKBOX = 7; REFERENCE = 8; DATE = 9; DATE_TIME = 10; LABEL = 11; BREAK = 12; MACRO = 14; UI_PAGE = 15; WIDE_SINGLE_LINE_TEXT = 16; MACRO_WITH_LABEL = 17; LOOKUP_SELECT_BOX = 18; CONTAINER_START = 19; CONTAINER_END = 20; LIST_COLLECTOR = 21; LOOKUP_MULTIPLE_CHOICE = 22; HTML = 23; SPLIT = 24; MASKED = 25;
|
||||
}
|
||||
$null = $MyArrayList.Add($obj)
|
||||
}
|
||||
|
||||
$params = @{
|
||||
Method = 'Get';
|
||||
Uri = ($Url + '/api/now/table/sc_item_option?sys_id=624e6fef47244610b7853238436d43a9');
|
||||
Headers = $SNOWSessionHeader;
|
||||
ContentType = 'application/json'
|
||||
}
|
||||
$x = Invoke-RestMethod @params
|
||||
|
||||
|
||||
|
||||
$params = @{
|
||||
Method = 'Get';
|
||||
Uri = ($Url + '/api/now/table/item_option_new_set?sys_id=5939ba3b47b04a90b7853238436d4372');
|
||||
Headers = $SNOWSessionHeader;
|
||||
ContentType = 'application/json'
|
||||
}
|
||||
$x = Invoke-RestMethod @params
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#variable set lookup scratch
|
||||
$params = @{
|
||||
Method = 'Get';
|
||||
Uri = ('https://northdakotadev.service-now.com/api/now/table/sc_req_item?sys_id=' + '3b94e3f1874e0a14a5aacbb6dabb35ac' + '&sysparm_limit=1000');
|
||||
Headers = $SNOWSessionHeader;
|
||||
ContentType = "application/json"
|
||||
}
|
||||
$x = (Invoke-RestMethod @params)
|
||||
|
||||
$params = @{
|
||||
Method = 'Get';
|
||||
Uri = ('https://northdakotadev.service-now.com/api/now/table/item_option_new_set?sys_id=' + '5939ba3b47b04a90b7853238436d4372' + '&sysparm_limit=1000');
|
||||
Headers = $SNOWSessionHeader;
|
||||
ContentType = "application/json"
|
||||
}
|
||||
$a = (Invoke-RestMethod @params).result
|
||||
|
||||
$params = @{
|
||||
Method = 'Get';
|
||||
Uri = ('https://northdakotadev.service-now.com/api/now/table/sc_cat_item');
|
||||
Headers = $SNOWSessionHeader;
|
||||
ContentType = "application/json"
|
||||
}
|
||||
$b = (Invoke-RestMethod @params).result
|
||||
$c = $b | Where-Object sys_id -EQ 'c64e27af47244610b7853238436d435d'
|
||||
|
||||
|
||||
$params = @{
|
||||
Method = 'Get';
|
||||
Uri = ('https://northdakotadev.service-now.com/api/now/table/item_option_new_set_list');
|
||||
Headers = $SNOWSessionHeader;
|
||||
ContentType = "application/json"
|
||||
}
|
||||
$d = (Invoke-RestMethod @params).result
|
||||
|
||||
$params = @{
|
||||
Method = 'Get';
|
||||
Uri = ('https://northdakotadev.service-now.com/api/now/table/sc_multi_row_question_answer');
|
||||
Headers = $SNOWSessionHeader;
|
||||
ContentType = "application/json"
|
||||
}
|
||||
$e = (Invoke-RestMethod @params).result
|
||||
|
||||
|
||||
<#
|
||||
sc_req_item --> sc_multi_row_question_answer.parent_id
|
||||
#>
|
||||
$RitmNum = 'RITM0233555'
|
||||
$RitmNum = 'RITM0231641'
|
||||
$Ritm = Get-ITDServiceNowRecord -ItemType 'Request Item' -Number $RitmNum
|
||||
|
||||
$params = @{
|
||||
Method = 'Get';
|
||||
Uri = ('https://northdakotadev.service-now.com/api/now/table/sc_multi_row_question_answer?parent_id=' + $Ritm.sys_id);
|
||||
Headers = $SNOWSessionHeader;
|
||||
ContentType = "application/json"
|
||||
}
|
||||
$AllRows = (Invoke-RestMethod @params).result
|
||||
|
||||
#$AllRows | Group-Object row_index ####### USE THIS TO SEPARATE EACH ROW ENTRY
|
||||
|
||||
#item_option gets value
|
||||
#vars gets name, type, question_text
|
||||
$Row_Indexes = ($AllRows | Select-Object -Unique row_index).row_index
|
||||
$ArrayList = [System.Collections.ArrayList]@()
|
||||
ForEach ($Row in $Row_Indexes) {
|
||||
$RowProperties = $AllRows | Where-Object row_index -EQ $Row
|
||||
|
||||
$obj = [PSCustomObject]@{
|
||||
}
|
||||
ForEach ($Property in $RowProperties) {
|
||||
$params = @{
|
||||
Method = 'Get';
|
||||
Uri = ("https://northdakotadev.service-now.com/api/now/table/item_option_new?sys_id=" + $Property.item_option_new.value);
|
||||
Headers = $SNOWSessionHeader;
|
||||
ContentType = "application/json"
|
||||
}
|
||||
$vars = (Invoke-RestMethod @params).result
|
||||
|
||||
$obj | Add-Member -MemberType NoteProperty -Name $vars.name -Value $Property.value
|
||||
|
||||
}
|
||||
$null = $ArrayList.Add($obj)
|
||||
}
|
||||
|
||||
|
||||
|
||||
$params = @{
|
||||
Method = 'Get';
|
||||
Uri = ();
|
||||
Headers = $SNOWSessionHeader;
|
||||
ContentType = "application/json"
|
||||
}
|
||||
|
||||
$CmdbCi = Get-ITDServiceNowRecord -Table cmdb_ci -SysId '4ac36cd11b0154509d7ada01dd4bcbdb'
|
||||
|
||||
|
||||
$params = @{
|
||||
Method = 'Get';
|
||||
Uri = "https://northdakota.service-now.com/api/now/table/sys_history_set?sys_id=" + 'ebb4a8cddbbf0254c4582fcb139619b9';
|
||||
Headers = $SNOWSessionHeader;
|
||||
ContentType = 'application/json'
|
||||
}
|
||||
Invoke-RestMethod @params -ov z
|
||||
|
||||
|
||||
|
||||
#### cmdb key values POC
|
||||
Get-ITDServiceNowRecord -Table 'cmdb_ci_win_server' -Filter @{name = 'itddotrtp2' }
|
||||
$z = Get-ITDServiceNowRecord -Table 'cmdb_key_value' -Filter @{name = 'itddotrtp2' }
|
||||
|
||||
$ComputerName = 'itddotrtp2'
|
||||
$CmdbCi = Get-ITDServiceNowRecord -Table 'cmdb_ci_server' -Filter ("name=$ComputerName")
|
||||
$KeyValues = Get-ITDServiceNowRecord -Table 'cmdb_key_value' -Filter ('configuration_item=' + $CmdbCi.sys_id.value)
|
||||
$KeyValues | Select-Object {$_.configuration_item.display_value},{$_.key.display_value},{$_.value.display_value}
|
||||
|
||||
# https://northdakotadev.service-now.com/now/nav/ui/classic/params/target/cmdb_key_value.do%3Fsys_id%3D31f4620bc38496505bc7d685e00131ac%26sysparm_record_target%3Dcmdb_key_value%26sysparm_record_row%3D2%26sysparm_record_rows%3D5%26sysparm_record_list%3Dconfiguration_item%253D67ba954bc30c121046637badc001311c
|
||||
# https://northdakotadev.service-now.com/now/nav/ui/classic/params/target/cmdb_key_value.do%3Fsys_id%3D31f4620bc38496505bc7d685e00131ab%26sysparm_record_target%3Dcmdb_key_value%26sysparm_record_row%3D1%26sysparm_record_rows%3D5%26sysparm_record_list%3Dconfiguration_item%253D67ba954bc30c121046637badc001311c
|
||||
@@ -0,0 +1,44 @@
|
||||
$Ritm = Get-ITDServiceNowRecord -ItemType 'Request Item' -Number 'RITM0252601' -IncludeVariableSet
|
||||
ForEach ($row in $Ritm.VariableSet) {
|
||||
$Ci = Get-ITDServiceNowRecord -Table 'cmdb_ci' -Filter ("name=" + $row.host_name.split('.')[0])
|
||||
$NewApplicationSvc = Get-ITDServiceNowRecord -Table cmdb_ci_service_auto -SysId $row.application_info
|
||||
$CustomObj = $row | select licensing_restrictions,support_hours,dr_protection
|
||||
<#Update-ITDServiceNowRecord -Table 'cmdb_ci' -SysId $Ci.sys_id.value -Values @{
|
||||
u_nd_application_svc = $NewApplicationSvc.name.display_value
|
||||
short_description = ($CustomObj | ConvertTo-Json)
|
||||
}#>
|
||||
}
|
||||
|
||||
# key values
|
||||
Get-ITDServiceNowRecord -Table 'cmdb_key_value' -Filter ('configuration_item=' + $Ci.sys_id.value)
|
||||
New-ITDServiceNowRecord -Table 'cmdb_key_value' -Values @{
|
||||
configuration_item = $ci.sys_id.value
|
||||
key = 'AppName';
|
||||
value = $NewApplicationSvc.name.display_value
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$Ritm = Get-ITDServiceNowRecord -ItemType 'Request Item' -Number 'RITM0252601' -IncludeVariableSet
|
||||
ForEach ($row in $Ritm.VariableSet) {
|
||||
$Ci = Get-ITDServiceNowRecord -Table 'cmdb_ci' -Filter ("name=itdzmtest666")
|
||||
$NewApplicationSvc = Get-ITDServiceNowRecord -Table cmdb_ci_service_auto -SysId $row.application_info
|
||||
$CustomObj = $row | select licensing_restrictions,support_hours,dr_protection
|
||||
Update-ITDServiceNowRecord -Table 'cmdb_ci' -SysId $Ci.sys_id.value -Values @{
|
||||
u_nd_application_svc = $NewApplicationSvc.name.display_value
|
||||
short_description = ($CustomObj | ConvertTo-Json)
|
||||
}
|
||||
}
|
||||
|
||||
# key values
|
||||
Get-ITDServiceNowRecord -Table 'cmdb_key_value' -Filter ('configuration_item=' + $Ci.sys_id.value)
|
||||
New-ITDServiceNowRecord -Table 'cmdb_key_value' -Values @{
|
||||
configuration_item = $ci.sys_id.value
|
||||
key = 'AppName';
|
||||
value = $NewApplicationSvc.name.display_value
|
||||
}
|
||||
|
||||
+170
@@ -0,0 +1,170 @@
|
||||
|
||||
# property expressions for only custom attributes
|
||||
$PropertyList = @(
|
||||
@{
|
||||
name = "name";
|
||||
expression = { $_.name.display_value };
|
||||
},
|
||||
@{
|
||||
name = "dns_domain";
|
||||
expression = { $_.dns_domain.display_value } ;
|
||||
},
|
||||
@{
|
||||
name = "environment";
|
||||
expression = { $_.environment.display_value } ;
|
||||
},
|
||||
@{
|
||||
name = 'operational_status';
|
||||
expression = { $_.operational_status.display_value };
|
||||
}
|
||||
@{
|
||||
name = 'sys_id';
|
||||
expression = { $_.sys_id.value };
|
||||
}
|
||||
@{
|
||||
name = 'sys_class_name';
|
||||
expression = { $_.sys_class_name.value }
|
||||
},
|
||||
@{
|
||||
name = "u_nd_type";
|
||||
expression = { $_.u_nd_type.display_value }
|
||||
},
|
||||
@{
|
||||
name = "u_nd_dr_protection";
|
||||
expression = { $_.u_nd_dr_protection.display_value };
|
||||
},
|
||||
@{
|
||||
name = "u_nd_licensing_restrictions";
|
||||
expression = { $_.u_nd_licensing_restrictions.display_value }
|
||||
},
|
||||
@{
|
||||
name = "u_nd_application_svc";
|
||||
expression = { $_.u_nd_application_svc.display_value }
|
||||
},
|
||||
@{
|
||||
name = "u_support_hours";
|
||||
expression = { $_.u_support_hours.display_value }
|
||||
},
|
||||
@{
|
||||
name = "u_srm_recovery_type";
|
||||
expression = { $_.u_srm_recovery_type.display_value }
|
||||
}
|
||||
)
|
||||
|
||||
# Get all Ci properties and sort them alphabetically
|
||||
# $Ci | Select-Object ([string[]]($Ci | Get-Member -MemberType NoteProperty | ForEach-Object{$_.Name} | Sort-Object))
|
||||
|
||||
$SharePointList = Get-ITDVMwareSharePointVMGuestList | Where-Object { $_.Status -ne 'Delete' -and $_.Status -ne 'Deleted' } | Sort-Object Title
|
||||
|
||||
# sync sharepoint to servicenow cmdb
|
||||
ForEach ($SPItem in $SharePointList) {
|
||||
try {
|
||||
Write-Verbose -Message ("Start " + $SPItem.Title) -Verbose
|
||||
$HostName = $SPItem.Title.split('.')[0]
|
||||
$Ci = Get-ITDServiceNowRecord -Table cmdb_ci_server -Filter "name=$HostName" | Select-Object -Property $PropertyList
|
||||
|
||||
#If ($null -eq $Ci.u_nd_dr_protection) {
|
||||
switch ($SPItem.DR_Protection) {
|
||||
'None' { $DRProtection = 'No DR' }
|
||||
'VMware: ABR' { $DRProtection = 'VMWare: ABR' }
|
||||
'VMware: RPO 0:15' { $DRProtection = 'VMWARE RPO: 0:15' }
|
||||
'VMware: RPO 0:30' { $DRProtection = 'VMWARE RPO: 0:30' }
|
||||
'VMware: RPO 1:00' { $DRProtection = 'VMWARE RPO: 1:00' }
|
||||
'VMware: RPO 2:00' { $DRProtection = 'VMWARE RPO: 2:00' }
|
||||
'VMware: RPO 4:00' { $DRProtection = 'VMWARE RPO: 4:00' }
|
||||
'VMware: RPO 8:00' { $DRProtection = 'VMWARE RPO: 8:00' }
|
||||
}
|
||||
If ($Ci.u_nd_dr_protection -ne $DRProtection) {
|
||||
Write-Verbose -Message ($Ci.Name + " dr_protection") -Verbose
|
||||
Update-ITDServiceNowRecord -Table cmdb_ci_server -SysId $Ci.sys_id -Values @{
|
||||
u_nd_dr_protection = $DRProtection;
|
||||
} | Out-Null
|
||||
}
|
||||
#
|
||||
|
||||
If ($null -eq $Ci.u_nd_licensing_restrictions) {
|
||||
Write-Verbose -Message ($Ci.Name + " licensing restrictions") -Verbose
|
||||
Update-ITDServiceNowRecord -Table cmdb_ci_server -SysId $Ci.sys_id -Values @{
|
||||
u_nd_licensing_restrictions = $SPItem.LicensingRestrictions;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
If ($null -eq $SPItem.SRM_RecoveryVMtype) {
|
||||
# do nothing
|
||||
}
|
||||
Else {
|
||||
|
||||
switch ($SPItem.SRM_RecoveryVMtype) {
|
||||
'Reserved' { $SRMRecoveryType = 'Reserved' }
|
||||
'Repurposed' { $SRMRecoveryType = 'Repurposed' }
|
||||
}
|
||||
|
||||
If ($Ci.u_srm_recovery_type -ne $SRMRecoveryType) {
|
||||
Write-Verbose -Message ($Ci.Name + " srm recovery type") -Verbose
|
||||
Update-ITDServiceNowRecord -Table cmdb_ci_server -SysId $Ci.sys_id -Values @{
|
||||
u_srm_recovery_type = $SRMRecoveryType;
|
||||
}
|
||||
}
|
||||
$SRMRecoveryType = $null
|
||||
}
|
||||
|
||||
If ($null -eq $Ci.u_support_hours) {
|
||||
Write-Verbose -Message ($Ci.Name + " support hours") -Verbose
|
||||
switch ($SPitem.Support_x0020_HoursId) {
|
||||
1 {
|
||||
$SupportHours = "All Day Every Day" ;
|
||||
}
|
||||
4 {
|
||||
$SupportHours = "All Week 500 to 2300";
|
||||
}
|
||||
11 {
|
||||
$SupportHours = "Weekdays 700 to 1800";
|
||||
}
|
||||
}
|
||||
Write-Verbose -Message ($Ci.name + $SupportHours)
|
||||
Update-ITDServiceNowRecord -Table cmdb_ci_server -SysId $Ci.sys_id -Values @{
|
||||
u_support_hours = $SupportHours
|
||||
} | Out-Null
|
||||
$SupportHours = $null
|
||||
}
|
||||
}
|
||||
|
||||
catch {
|
||||
$Hostname | Add-Content "C:\temp\syncerrors.txt"
|
||||
}
|
||||
Write-Verbose -Message ("End " + $SPItem.Title) -Verbose
|
||||
}
|
||||
|
||||
|
||||
Get-ITDServiceNowRecord -Table cmdb_ci_server | Select-Object Name, dns_domain
|
||||
|
||||
|
||||
Get-ITDServiceNowRecord -Table cmdb_ci_server -Filter "name=itdnet35p1" | Select-Object $PropertyList
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$Filter = '&$select=ID,Title,Status,Network/Vlan_Id,Network/CIDR,AppName/Title,Cluster/Name,Support_x0020_Hours/Hours&$expand=Network/Id,AppName/Id,Cluster/Id,Support_x0020_Hours/Id'
|
||||
$URLVMItems = "https://share.nd.gov/itd/computer-systems/distributed-systems/vmware/_api/lists/getbytitle('VM Guests')/items?" + '$top=10000' + $Filter
|
||||
|
||||
|
||||
|
||||
|
||||
$Filter = '&$select=ID,Title,Support_x0020_Hours/Hours&$expand=Support_x0020_Hours/Id'
|
||||
$URLVMItems = "https://share.nd.gov/itd/computer-systems/distributed-systems/vmware/_api/lists/getbytitle('VM Guests')/items?" + '$top=10000'
|
||||
|
||||
$InvokeWebRequestParams = @{
|
||||
Uri = $URLVMItems;
|
||||
Method = "Get";
|
||||
headers = @{ "Accept" = "application/json;odata=verbose" };
|
||||
UseBasicParsing = $true;
|
||||
}
|
||||
|
||||
If ($Credential) { $InvokeWebRequestParams += @{Credential = $Credential } }
|
||||
Else { $InvokeWebRequestParams += @{UseDefaultCredentials = $true } }
|
||||
|
||||
#$z = (Invoke-WebRequest -Uri $URL -Method Get -UseDefaultCredentials -headers @{ "Accept" = "application/json;odata=verbose" }) -creplace '"Id":', '"Idx":' | ConvertFrom-Json
|
||||
$z = (Invoke-WebRequest @InvokeWebRequestParams) -creplace '"Id":', '"Idx":' | ConvertFrom-Json
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
#### report on the differences between the SharePoint list and the CMDB
|
||||
|
||||
function Compare-ITDVMSharePointToCmdb {
|
||||
[CmdletBinding()]
|
||||
param (
|
||||
|
||||
)
|
||||
|
||||
begin {
|
||||
|
||||
$SPList = Get-ITDVMwareSharePointVMGuestList | Where-Object { $_.Status -ne "Delete" -and $_.Status -ne "Deleted" -and $_.Status -ne "Declined"}
|
||||
|
||||
$ArrayList = [System.Collections.ArrayList]@()
|
||||
ForEach ($SPItem in $SPList) {
|
||||
Write-Verbose -message ($SPItem.Title) -Verbose
|
||||
$Cmdb = $null
|
||||
$Hostname = $null
|
||||
$obj = $null
|
||||
|
||||
$Hostname = $SPItem.Title.split('.')[0]
|
||||
$Cmdb = Get-ITDServiceNowRecord -Table cmdb_ci_server -Filter "name=$HostName"
|
||||
|
||||
$obj = [PSCustomObject]@{
|
||||
SPTitle = $SPItem.Title;
|
||||
CmdbHostName = $Cmdb.name.display_value;
|
||||
Environment = $null;
|
||||
AppName = $null;
|
||||
LicensingRestrictions = $null;
|
||||
DR_Protection = $null;
|
||||
SRMRecoveryType = $null;
|
||||
}
|
||||
|
||||
If ($SPItem.Environment -eq $Cmdb.Environment.display_value) {
|
||||
$obj.Environment = $true
|
||||
} Else {
|
||||
$obj.Environment = $false
|
||||
}
|
||||
|
||||
If ($SPItem.AppName -eq $Cmdb.u_nd_application_svc.display_value) {
|
||||
$obj.AppName = $true
|
||||
} Else {
|
||||
$obj.AppName = $false
|
||||
}
|
||||
|
||||
If ($SPItem.LicensingRestrictions -eq $Cmdb.u_nd_licensing_restrictions.display_value) {
|
||||
$obj.LicensingRestrictions = $true
|
||||
} Else {
|
||||
$obj.LicensingRestrictions = $false
|
||||
}
|
||||
|
||||
switch ($SPItem.DR_Protection) {
|
||||
'None' {
|
||||
If ($Cmdb.u_nd_dr_protection.display_value -eq 'No DR') {
|
||||
$obj.DR_Protection = $true
|
||||
}
|
||||
Else {
|
||||
$obj.DR_Protection = $false
|
||||
}
|
||||
}
|
||||
'VMware: ABR' {
|
||||
If ($Cmdb.u_nd_dr_protection.display_value -eq 'VMware: ABR') {
|
||||
$obj.DR_Protection = $true
|
||||
}
|
||||
Else {
|
||||
$obj.DR_Protection = $false
|
||||
}
|
||||
}
|
||||
Default {
|
||||
If ($Cmdb.u_nd_dr_protection.display_value -eq $SPItem.DR_Protection) {
|
||||
$obj.DR_Protection = $true
|
||||
}
|
||||
Else {
|
||||
$obj.DR_Protection = $false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch ($SPItem.SRM_RecoveryVMtype) {
|
||||
$null {
|
||||
If ($null -eq $Cmdb.u_nd_srm_recovery_vm_type.display_value) {
|
||||
$obj.SRMRecoveryType = $true
|
||||
}
|
||||
Else {
|
||||
$obj.SRMRecoveryType = $false
|
||||
}
|
||||
}
|
||||
'Reserved' {
|
||||
If ($Cmdb.u_srm_recovery_type.display_value -eq 'Reserved') {
|
||||
$obj.SRMRecoveryType = $true
|
||||
}
|
||||
Else {
|
||||
$obj.SRMRecoveryType = $false
|
||||
}
|
||||
}
|
||||
'Repurposed' {
|
||||
If ($Cmdb.u_srm_recovery_type.display_value -eq 'Repurposed') {
|
||||
$obj.SRMRecoveryType = $true
|
||||
}
|
||||
Else {
|
||||
$obj.SRMRecoveryType = $false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$ArrayList.Add($obj) | Out-Null
|
||||
}
|
||||
}
|
||||
|
||||
process {
|
||||
|
||||
}
|
||||
|
||||
end {
|
||||
Write-Output $ArrayList
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
$INCs=@"
|
||||
INC0517190
|
||||
INC0517191
|
||||
INC0517192
|
||||
INC0517193
|
||||
"@
|
||||
|
||||
$INCs = ConvertTo-Array -MultiLineString $INCs
|
||||
|
||||
ForEach($IncNum in $INCs){
|
||||
Update-ITDServiceNowRecord -ItemType Incident -Number $IncNum -Values @{
|
||||
work_notes = 'new VMs deployed via OVA... added missing tags';
|
||||
close_notes = 'new VMs deployed via OVA... added missing tags';
|
||||
close_code = 'Solved (Permanently)';
|
||||
u_underlying_cause = 'Configuration'
|
||||
category = 'sp_systems';
|
||||
subcategory = 'sp_backup';
|
||||
assigned_to = "Zachary L Meier";
|
||||
state = 'Closed';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
$VMHostNames=@('itdvmnrmsec01.nd.gov')
|
||||
|
||||
# New-ITDServiceNowChangeRequest
|
||||
$VMHostNames | ForEach-Object {
|
||||
$NewITDServiceNowChangeRequestParams = @{
|
||||
#TemplateName = 'NDIT-SPS-Server Add/Chg/Del'
|
||||
RequestedByUsername = 'zmeier';
|
||||
Category = 'Systems Platforms - Systems';
|
||||
Subcategory = 'VMware';
|
||||
Impact = 3;
|
||||
ShortDescription = "Firmware and software updates for $_";
|
||||
Description = "Following HPE VMware firmware/software recipe for 2024.04.01: HPE ProLiant Firmware Update and VMware upgrade to v7.0 U3p. The entire process will take 6-8 hours per server. http://vibsdepot.hpe.com/customimages/Valid-vLCM-Combos.pdf";
|
||||
Justification = "Required for continued support";
|
||||
Implementation = "install";
|
||||
RiskImpactAnalysis = "Low - VMware hosts running on the HPE ProLiant platforms will be shutdown. All active virtual machine workloads will be migrated to other hosts in their respective clusters during the maintenance. No outage expected.";
|
||||
BackoutPlan = "n/a"
|
||||
TestPlan = "n/a"
|
||||
WhoIsImpacted = "n/a";
|
||||
StartTime = (Get-Date)
|
||||
EndTime = (Get-Date).AddHours(8);
|
||||
AssignmentGroup = 'NDIT-Computer Systems Windows';
|
||||
ChangeManagerUsername = 'khellman';
|
||||
ChangeCoordinatorUsername = 'gpgolberg';
|
||||
AssignedToUsername = 'zmeier';
|
||||
}
|
||||
|
||||
$CHG = New-ITDServiceNowChangeRequest @NewITDServiceNowChangeRequestParams
|
||||
}
|
||||
# To-do list
|
||||
# Confirm-ITDServiceNowChangeRequest
|
||||
|
||||
$CHGNums = @"
|
||||
CHG0143889
|
||||
CHG0143888
|
||||
CHG0143887
|
||||
CHG0143886
|
||||
CHG0143885
|
||||
CHG0143884
|
||||
CHG0143883
|
||||
"@
|
||||
|
||||
$CHGNums = ConvertTo-Array -MultiLineString $CHGNums
|
||||
|
||||
$CHGNums | ForEach-Object {
|
||||
Complete-ITDServiceNowChangeRequest -Number $_ -CloseCode "Successful" -CloseNotes "Firmware and software installed." #$CHG.Number.value
|
||||
}
|
||||
|
||||
|
||||
|
||||
# use standard CHG template NDIT-SPS-Server Add/Chg/Del
|
||||
<# ps lifecycle verbs
|
||||
submit --- new
|
||||
approve / deny --- skip if std chg
|
||||
schedule --- ???
|
||||
implement --- ???
|
||||
confirm --- implement and review
|
||||
complete --- close
|
||||
#>
|
||||
# date/time testing
|
||||
Update-ITDServiceNowRecord -ItemType 'Change Request' -Number CHG0098995 -Values @{
|
||||
start_date = (Get-Date -Year 2023 -Month 1 -Day 1 -Hour 0 -Minute 0 -Second 0 -AsUTC).ToString('yyyy-MM-dd HH:mm:ss');
|
||||
end_date = (Get-Date -AsUTC).AddMinutes(1).ToString('yyyy-MM-dd HH:mm:ss')
|
||||
}
|
||||
|
||||
|
||||
|
||||
# New-ITDServiceNowServiceCatalogRequest
|
||||
$NewITDServiceNowServiceCatalogRequest = @{
|
||||
CategoryItemName = "Application Server";
|
||||
RequestedForEmail = 'zmeier@nd.gov';
|
||||
Values = @{
|
||||
request_type = "";
|
||||
application_name = "";
|
||||
environment = "";
|
||||
require_hosting_quote = 'No';
|
||||
server_name = '';
|
||||
add_change_disaster_recovery = 'No';
|
||||
additional_comments = "";
|
||||
};
|
||||
}
|
||||
|
||||
New-ITDServiceNowServiceCatalogRequest @NewITDServiceNowServiceCatalogRequest
|
||||
|
||||
|
||||
|
||||
|
||||
# New Server Build Request x1
|
||||
# server name
|
||||
$ServerName = 'itdzmtest559.nd.gov'
|
||||
|
||||
# Subnet lookup
|
||||
$Subnet = '10.11.12.0/23' ### review these lookup fields\
|
||||
$cidr_block = Get-ITDServiceNowRecord -Table 'cmdb_ci_ip_network' -Filter "name=$Subnet"
|
||||
|
||||
# Agency lookup
|
||||
$AgencyPrefix = "ITD"
|
||||
switch ($AgencyPrefix) {
|
||||
'ITD' { $AgencyNum = '112.0' }
|
||||
}
|
||||
$Agency = Get-ITDServiceNowRecord -Table 'cmn_department' -Filter "id=$AgencyNum"
|
||||
|
||||
# team lead lookup
|
||||
$team_lead = Get-ITDServiceNowUser -Email 'gpgolberg@nd.gov'
|
||||
|
||||
# AppName lookup
|
||||
$AppName = "Infra-VMware"
|
||||
$application_info = Get-ITDServiceNowRecord -Table cmdb_ci_service -Filter ("name=$AppName")
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
function Get-ITDVMSharePointCmdbDiff {
|
||||
[CmdletBinding()]
|
||||
param (
|
||||
[string]
|
||||
$FQDN
|
||||
)
|
||||
|
||||
begin {
|
||||
|
||||
}
|
||||
|
||||
process {
|
||||
$SPItem = Get-ITDVMwareSharePointVMGuestList | Where-Object { $_.Status -ne "Delete" -and $_.Status -ne "Deleted" } | Where-Object { $_.Title -eq $FQDN }
|
||||
|
||||
$Cmdb = $null
|
||||
$Hostname = $null
|
||||
$obj = $null
|
||||
|
||||
$Hostname = $SPItem.Title.split('.')[0]
|
||||
$Cmdb = Get-ITDServiceNowRecord -Table cmdb_ci_server -Filter "name=$HostName"
|
||||
|
||||
$obj = [PSCustomObject]@{
|
||||
SpPTitle = $SPItem.Title;
|
||||
CmdbHostName = $Cmdb.name.display_value;
|
||||
SpEnvironment = $SPItem.Environment;
|
||||
CmdbEnvironment = $Cmdb.environment.display_value;
|
||||
SpAppName = $SPItem.AppName;
|
||||
CmdbAppName = $Cmdb.u_nd_application_svc.display_value;
|
||||
SpLicensingRestrictions = $SPItem.LicensingRestrictions;
|
||||
CmdbLicensingRestrictions = $Cmdb.u_nd_licensing_restrictions.display_value;
|
||||
SpDR_Protection = $SPItem.DR_Protection;;
|
||||
CmdbDR_Protection = $Cmdb.u_nd_dr_protection.display_value;
|
||||
SpSRMRecoveryType = $SPItem.SRM_RecoveryVMtype;
|
||||
CmdbSRMRecoveryType = $Cmdb.u_srm_recovery_type.display_value;
|
||||
}
|
||||
}
|
||||
|
||||
end {
|
||||
Write-Output $obj
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user