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
# we aren't aware of this table, create default config
54
+
$thisTable=@{
55
+
Name=$Table
56
+
ClassName=$null
57
+
Type=$null
58
+
NumberPrefix=$null
59
+
DescriptionField=$null
60
+
}
61
+
}
62
+
}
63
+
64
+
if ( $ID ) {
65
+
if ( $ID-match'^[a-zA-Z0-9]{32}$' ) {
66
+
if ( -not$thisTable ) {
67
+
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.'
68
+
}
69
+
70
+
$thisID=$ID
71
+
}
72
+
else {
73
+
if ( -not$thisTable ) {
74
+
# get table name from prefix if only Id was provided
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', '))
80
+
}
81
+
}
82
+
83
+
if ( $AsSysId ) {
84
+
$getParams=@{
85
+
Table=$thisTable.Name
86
+
Filter=@('number','-eq',$ID)
87
+
Property='sys_class_name','sys_id','number'
88
+
Connection=$Connection
89
+
ServiceNowSession=$ServiceNowSession
90
+
}
91
+
92
+
$thisRecord=Invoke-ServiceNowRestMethod@getParams
93
+
94
+
if ( -not$thisRecord ) {
95
+
throw ('Table: {0}, ID: {1} not found'-f$thisTable.Name,$ID)
$thisTableName=$ServiceNowTable.Where{ $_.ClassName-eq$Table } |Select-Object-ExpandProperty Name
123
-
if ( -not$thisTableName ) {
124
-
$thisTableName=$Table
125
-
}
126
-
}
127
-
128
-
if ( $ID-match'^[a-zA-Z0-9]{32}$' ) {
129
-
if ( -not$thisTableName ) {
130
-
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', '))
If ((Test-Path$outFile) -and-not$AllowOverwrite.IsPresent) {
120
+
If ((Test-Path$outFile) -and-not$AllowOverwrite) {
108
121
throw ('The file ''{0}'' already exists. Please choose a different name, use the -AppendNameWithSysID switch parameter, or use the -AllowOverwrite switch parameter to overwrite the file.'-f$OutFile)
109
122
}
110
123
111
124
$params.OutFile=$outFile
112
125
}
113
126
114
-
If ($PSCmdlet.ShouldProcess($outFile,"Save attachment")) {
127
+
If ($PSCmdlet.ShouldProcess($ID,"Export attachment")) {
0 commit comments