Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Why won't my ntdsutil command execute successfully from my Posh script?

$
0
0

Hello,

The purpose of the script is to delete snapshot versions using ntdsutil.

The script starts and executes a  '$SnapShotList = ntdsutil snapshot "list all" quit quit' to list current snapshots as indicated below.  I then parse through these and based on age I construct and submit a ntdsutil command as follows,

cmd /c ntdsutil snapshot "Delete$SnapShotNumber" quit quit

but I always get a 'Invalid Snapshot Index 1.' $SnapShotNumber is a string variable with the number of the snapshot I want to delete.  I tried removing the 'cmd /c', but same results.  This command works find from the Command Prompt.  Any suggestions?

C:\windows\system32\ntdsutil.exe: snapshot

snapshot: list all

1: 2014/01/26:13:25 {6f58b7ee-2fc8-468b-a17d-55e7634c8259}

2:   C: {39200929-b206-4055-9333-ef6c7a096250} 

  

3: 2014/01/26:13:50 {d580d82e-ba0f-466b-ac77-fcc4f6ed4532}

4:   C: {5ccd0e27-cb4a-4002-8a5b-9b582fc2e694} 

  

5: 2014/01/26:15:06 {350c7788-114d-440c-afab-5a59def997a5}

6:   C: {c01fd8d1-d006-4b8e-9fbc-8a65c2abe37b} 

  

7: 2014/01/26:15:11 {7b5f2558-a928-4ada-9c37-239c99ece330}

8:   C: {f64fc410-a4e4-4eba-8c99-2d402efc21f1} 

  

9: 2014/01/26:16:19 {b32cd4e9-6d0c-4745-bc23-da20a7696b5e}

10:   C: {337e0cb1-6e0d-4dd3-8425-b4797160ed20} 

  

11: 2014/01/26:18:00 {82aa5be6-0cef-4e39-8016-99eb3af9058b}

12:   C: {dca91ff4-a045-48b5-95b7-4544b692bbb3} 

  

snapshot: quit

C:\windows\system32\ntdsutil.exe: quit

  

PS C:\windows\system32>  


Thanks for your help! SdeDot


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>