File tree Expand file tree Collapse file tree 1 file changed +19
-7
lines changed
Expand file tree Collapse file tree 1 file changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -23,16 +23,28 @@ protected override void ExecuteCmdlet()
2323 {
2424 if ( ParameterSpecified ( nameof ( Identity ) ) )
2525 {
26- var recycleBinItem = Identity . GetRecycleBinItem ( Connection . PnPContext ) ;
27-
28- if ( recycleBinItem == null )
26+ // if Identity has item, use it
27+ if ( Identity . Item != null )
2928 {
30- throw new PSArgumentException ( "Recycle bin item not found with the ID specified" , nameof ( Identity ) ) ;
29+ if ( Force || ShouldContinue ( string . Format ( Resources . RestoreRecycleBinItem , Identity . Item . LeafName ) , Resources . Confirm ) )
30+ {
31+ Identity . Item . Restore ( ) ;
32+ ClientContext . ExecuteQueryRetry ( ) ;
33+ }
3134 }
32-
33- if ( Force || ShouldContinue ( string . Format ( Resources . RestoreRecycleBinItem , recycleBinItem . LeafName ) , Resources . Confirm ) )
35+ else
3436 {
35- recycleBinItem . Restore ( ) ;
37+ var recycleBinItem = Identity . GetRecycleBinItem ( Connection . PnPContext ) ;
38+
39+ if ( recycleBinItem == null )
40+ {
41+ throw new PSArgumentException ( "Recycle bin item not found with the ID specified" , nameof ( Identity ) ) ;
42+ }
43+
44+ if ( Force || ShouldContinue ( string . Format ( Resources . RestoreRecycleBinItem , recycleBinItem . LeafName ) , Resources . Confirm ) )
45+ {
46+ recycleBinItem . Restore ( ) ;
47+ }
3648 }
3749 }
3850 else
You can’t perform that action at this time.
0 commit comments