You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$thisTableName=$ServiceNowTable.Where{ $_.ClassName-eq$Table } |Select-Object-ExpandProperty Name
114
+
if ( -not$thisTableName ) {
115
+
$thisTableName=$Table
116
+
}
90
117
}
91
-
$tableRecord=Get-ServiceNowRecord@getParams
92
118
93
-
if ( -not$tableRecord ) {
94
-
Write-Error"Record not found for Id '$Id'"
95
-
continue
96
-
}
119
+
if ( $ID-match'^[a-zA-Z0-9]{32}$' ) {
120
+
if ( -not$thisTableName ) {
121
+
Write-Error'Providing sys_id for -Id requires a value for -Table. Alternatively, provide an -Id with a prefix, eg. INC1234567, and the table will be automatically determined.'
Write-Error ('The prefix for Id ''{0}'' was not found and the appropriate table cannot be determined. Known prefixes are {1}. Please provide a value for -Table.'-f$ID, ($ServiceNowTable.NumberPrefix.Where( { $_ }) -join', '))
Copy file name to clipboardExpand all lines: ServiceNow/Public/Export-ServiceNowRecord.ps1
+7-7Lines changed: 7 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -87,7 +87,7 @@ function Export-ServiceNowRecord {
87
87
}
88
88
})]
89
89
[Alias('sys_id','number')]
90
-
[string] $Id,
90
+
[string] $ID,
91
91
92
92
[Parameter()]
93
93
[Alias('Fields','Properties')]
@@ -123,24 +123,24 @@ function Export-ServiceNowRecord {
123
123
$thisTable=$Table
124
124
}
125
125
126
-
if ( $Id ) {
127
-
if ( $Id-match'^[a-zA-Z0-9]{32}$' ) {
126
+
if ( $ID ) {
127
+
if ( $ID-match'^[a-zA-Z0-9]{32}$' ) {
128
128
if ( -not$thisTable ) {
129
129
throw'Providing sys_id for -Id requires a value for -Table. Alternatively, provide an Id with a prefix, eg. INC1234567, and the table will be automatically determined.'
130
130
}
131
131
132
-
$newFilter=@('sys_id','-eq',$Id)
132
+
$newFilter=@('sys_id','-eq',$ID)
133
133
} else {
134
134
if ( -not$thisTable ) {
135
135
# get table name from prefix if only Id was provided
$thisTable=$script:ServiceNowTable|Where-Object { $_.NumberPrefix-and$idPrefix-eq$_.NumberPrefix } |Select-Object-ExpandProperty Name
139
139
if ( -not$thisTable ) {
140
-
throw ('The prefix for Id ''{0}'' was not found and the appropriate table cannot be determined. Known prefixes are {1}. Please provide a value for -Table.'-f$Id, ($ServiceNowTable.NumberPrefix.Where( { $_ }) -join', '))
140
+
throw ('The prefix for Id ''{0}'' was not found and the appropriate table cannot be determined. Known prefixes are {1}. Please provide a value for -Table.'-f$ID, ($ServiceNowTable.NumberPrefix.Where( { $_ }) -join', '))
0 commit comments