Перейти из форума на сайт.

НовостиФайловые архивы
ПоискАктивные темыТоп лист
ПравилаКто в on-line?
Вход Забыли пароль? Первый раз на этом сайте? Регистрация
Компьютерный форум Ru.Board » Операционные системы » Microsoft Windows » Сценарии для Windows

Модерирует : KLASS, IFkO

 Версия для печати • ПодписатьсяДобавить в закладки
На первую страницук этому сообщениюк последнему сообщению

Открыть новую тему     Написать ответ в эту тему

iNNOKENTIY21



Silver Member
Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору

Код:
1 class MountedDiskImage {
2    # Файл образа диска
3    [Parameter(Mandatory)]
4    [ValidateNotNullOrEmpty()]
5    [Alias("FullName")]
6    [IO.FileInfo]
7    $Path
8
9    [Parameter(Mandatory)]
10    [ValidateNotNullOrEmpty()]
11    [Microsoft.Management.Infrastructure.CimInstance]
12    $Image
13
14    [Parameter(Mandatory)]
15    [ValidateNotNullOrEmpty()]
16    [char]
17    $DriveLetter
18
19    MountedDiskImage() { }
20
21    MountedDiskImage($Path) {
22        $this.Path  = $Path
23        $this.Image = $this.GetImage()
24
25        if (-not ($this.Image.Attached)) {
26            $this.Mount()
27        }
28
29        $this.GetDriveLetter()
30    }
31
32    hidden [Microsoft.Management.Infrastructure.CimInstance] GetImage() {
33        return Get-DiskImage -ImagePath $this.Path
34    }
35
36    hidden [void] GetDriveLetter() {
37        switch ($this.Image.StorageType) {
38            1       { $this.GetDriveLetterISO() }
39            2       { $this.GetDriveLetterVHD() }
40            3       { $this.GetDriveLetterVHD() }
41            Default { throw "Неизвестный тип хранения образа диска" }
42        }
43    }
44
45    hidden [void] Mount() {
46        $this.Image = Mount-DiskImage -ImagePath $this.Path
47    }
48
49    hidden [void] GetDriveLetterISO() {
50        $this.DriveLetter = ($this.Image | Get-Volume).DriveLetter
51    }
52
53    hidden [void] GetDriveLetterVHD() {
54        $this.DriveLetter = (
55            $this.Image | Get-Disk | Get-Partition | Get-Volume
56        ).DriveLetter
57    }
58 }

Всего записей: 3521 | Зарегистр. 16-08-2012 | Отправлено: 15:24 19-01-2020
Открыть новую тему     Написать ответ в эту тему

На первую страницук этому сообщениюк последнему сообщению

Компьютерный форум Ru.Board » Операционные системы » Microsoft Windows » Сценарии для Windows


Реклама на форуме Ru.Board.

Powered by Ikonboard "v2.1.7b" © 2000 Ikonboard.com
Modified by Ru.B0ard
© Ru.B0ard 2000-2024

BitCoin: 1NGG1chHtUvrtEqjeerQCKDMUi6S6CG4iC

Рейтинг.ru