有没有办法可以将我的外部硬盘捕获为可移动驱动器

问题描述

我是 powershell 的新手,我正在编写一个脚本,该脚本将在连接可移动驱动器时执行某些操作。我已经用三个 USB 闪存驱动器尝试了这个脚本,一切都很好。我尝试使用我的东芝 canvio 基本外置硬盘,但它不起作用(任务未执行)。我使用的是 Windows 10 计算机。

这是我用来检查 USB 活动的 powershell 命令

{% for post in blog_posts %}

    <h1>{{ post.chief_title }}</h1>
    <p>{{ post.author }} says: </p>
    <b>{{ post.body }}</b>
    <p> This post is liked by: </p>
    {% for user in post.likes %}
        <p>{{ user.username }}</p>
    {% endfor %}
    
    {% if request.user not in post.likes.all %} 
        <a href="{% url 'like_post' post.slug %}">Like</a>
    {% else %} 
        <a href="{% url 'like_post' post.slug %}">Unlike</a>
    {% endif %}

{% endfor %}

我还注意到,当执行 cmdlet $wmiParameters = @{ Query = "select * from __InstanceCreationEvent within 5 where TargetInstance ISA 'Win32_Logicaldisk' and TargetInstance.DriveType = 2" SourceIdentifier = "USBDrive" MessageData = "Test" TimeOut = 500 Action = { & $PSScriptRoot\script.ps1 } } Register-WmiEvent @wmiParameters 时,东芝硬盘的驱动器类型是固定的,但我的闪存驱动器的驱动器类型是可移动的,而我不知道不知道如何影响我的脚本或如何修复它。

Results for cmdlet Get-Volume

我如何修改我的代码以便它可以捕获我的外置硬盘,或者我如何修改我的设置以便我的外置硬盘被视为可移动驱动器? 谢谢你。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)