I am stuck in a problem for few days now, i need to create a script to rename a file or folder on remote machine in my environment. The problem, i cannot use psremoting as the service and ports required are blocked and cannot, i cannot use CIM_instance as well as the service is disabled or psexec tool. The only way i can reach remote machine is by WMI_Object method. I can get to the folder on remote machine but can’t rename or delete it. The script i am using to get to the folder is below:-
.delete() and .rename(‘filename’) are instance methods (there’s no static qualifier). Usually only the create type methods are static. This worked for me locally at least. Have to double the backslash if you use a wql (sql) filter. Or you could pipe to where, but it’s much slower, since it’s returning every directory. I just took a Pluralsight class on using wmi and cim in powershell. ‘root\cimv2’ is the default namespace, so you don’t have to specify it.