如何解决如何使用pywinrm连接不同域中的主机?
我正在尝试使用pywinrm连接其他域中的主机,但这会导致权限错误,我指的是以下文章,但这对我不起作用:在How to connect to remote machine via WinRM in Python (pywinrm) using domain account?
只需要登录即可,并且通过python脚本仅执行监视该域内文件夹更改/更新的任务。
import os
import sys
import time
import logging
from watchdog.observers import Observer
from watchdog.events import LoggingEventHandler
import winrm
s = winrm.Session('HOST',auth=('username@domain','password'))
if __name__ == "__main__":
logging.basicConfig(level=logging.INFO,format='%(asctime)s - %(message)s',datefmt='%Y-%m-%d %H:%M:%S')
os.system('\\Networkip\Community\Onbase\Onbase Imports')
print("found")
# Defining your own path
path = "//Networkip/Community/Onbase/Onbase Imports/Unindexed Documents/Drop"
print("found")
# Initilaize logging event handler
event_handler = LoggingEventHandler()
# Initialize Observer
observer = Observer()
observer.schedule(event_handler,path,recursive=True)
# Start the observer
observer.start()
try:
while True:
# set the thread sleep time
time.sleep(1)
except KeyboardInterrupt:
observer.stop()
observer.join()
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。