Comments (2)
Dirty cheap solution: Script to do the reg hack to stop warnings, call ocsinventory and revert registry to it's initial state.
Another possibility is to create two dumb plugins to do the registry things. In that case take in care that vbs are run first and ps1 later on.
from windowsagent.
FWIW, I mark the question as closed. I paste the piece of code I wrote to get it working. In my case I try to leave the computer registry in the previous state when OCSInventory has finished. If not wanted, most of the function code can be deleted.
`#*****************************************************************
Script: ocsUNC.ps1
Version: 1.0
Autor: Jon de Isusi
Date: 20/10/2017
Descripción: ejecución de OCSInventory desde una ruta UNC sin necesidad de hacer mapeos
Se modifica el registro y luego se revierte al estado anterior
#*****************************************************************
definiciones
$sOCS = "OCSinventory.exe"
$sOCSdir = "\RUTAUNC\CARPETAOCS"
$sOCSurl = "https://servidorocs/ocsinventory"
$sOCScert = "certificado.cer"
$sargs_OCS = "/NO_SERVICE /S /SERVER=$sOCSurl /NOTAG /hkcu /ssl=1 /ca=""$sOCScert"""
función para habilitar o deshabilitar los mensajes de UNC teniendo en cuenta un estado anterior
se generan 2 valores para guardar el valor anterior y controlar que no se esté en medio de una ejecución
Function controlarUNCWarning ( [bool]$bHabilitar ){
$REGKEY = "HKCU:\Software\Microsoft\Command Processor"
$VALOR = "DisableUNCCheck"
$VALORBACKUP = "DisableUNCCheckBackup"
$VALOREXEC = "OCSExec"
if ( -not ($bHabilitar) ) {
# deshabilitar mensajes de warning
try{
if ( (Get-ItemPropertyValue -Path $REGKEY -Name $VALOR ) -eq 0){
# estaba a 0, lo ponemos a 1
New-ItemProperty -Path $REGKEY -Name $VALOR -Value 1 -PropertyType DWORD -Force | Out-Null
} else {
try{
# get-itempropertyvalue a la fecha actual no admite erroraction silentlycontinue.
# revisamos que no esté en medio de una ejecución
Get-ItemPropertyValue -Path $REGKEY -Name $VALOREXEC | Out-Null
} catch {
# ya existía a 1 y no estamos en una ejecución, creamos una copia del valor para luego restaurarla
New-ItemProperty -Path $REGKEY -Name $VALORBACKUP -Value 1 -PropertyType DWORD -Force | Out-Null
}
}
} catch {
# no existe el valor, se crea
New-ItemProperty -Path $REGKEY -Name $VALOR -Value 1 -PropertyType DWORD -Force | Out-Null
}
try{
# se crea un valor de control de ejecución por si se para
New-ItemProperty -Path $REGKEY -Name $VALOREXEC -Value 1 -PropertyType DWORD -Force | Out-Null
} catch {
}
} else {
# habilitar mensajes de warning
try{
if (Get-ItemPropertyValue -Path $REGKEY -Name $VALORBACKUP){
# al deshabilitarlos el valor ya estaba a 1. Se creó una copia que ahora borramos
Remove-ItemProperty -Path $REGKEY -Name $VALORBACKUP -Force -ErrorAction SilentlyContinue
}
} catch {
# no había copia, así que dejamos el equipo limpio
Remove-ItemProperty -Path $REGKEY -Name $VALOR -Force -ErrorAction SilentlyContinue
}
# borramos el control de ejecución
Remove-ItemProperty -Path $REGKEY -Name $VALOREXEC -Force -ErrorAction SilentlyContinue
}
}
ejecución
if (test-path $sOCSdir){
Set-Location "$sOCSdir"
controlarUNCWarning $false
Start-Process $sOCS -Arg $sargs_OCS -Wait
controlarUNCWarning $true
}
`
from windowsagent.
Related Issues (20)
- Store file/folder => le fichier arrive sur le client avec l'attribut 'Caché' (Hidden) dans le répertoire de destination HOT 4
- WOL doesn't work HOT 1
- Agent Windows 2.10.0.0 - 32 bits version not released HOT 3
- Impossible de démarrer le programme car il manque api-ms-win-crt-heap-l1-1-0.dll HOT 6
- 64 Bit OCS Agent not working because of Saas.ps1 HOT 2
- Systray icon showed when using /no_systray HOT 4
- CA certificate on different drive does not work HOT 2
- How to manually create the .xml file for the inventory? HOT 1
- Simple user can't see anymore inventory from systray- bad permission HOT 1
- Agent Windows 2.10.1.0 causes duplicate entries (lowercase and uppercase) HOT 7
- Adaptation of the plugin 'Saas.ps1' (Web application Inventory) for German clients
- OCS Agent dectectinf Windows 10 as Windows 8
- My OCS Inventory Console shows the same computer more than one time HOT 1
- Windows Agent service throw error and can't make inventory
- [Request] add option to scan users installed programs
- ERROR *** AGENT => Failed to send Prolog <HTTP Status Code #500> HOT 6
- OCS Windows Agent 2.10.1.0 x86 keeps crashing
- Software installed from Microsoft Store is not retrieved HOT 2
- Problems with inventory, nothing appears on the server HOT 1
- OCS service is randomly uninstalled
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from windowsagent.