Appunti di fotografia [171] – L’auto-like
L’auto-like sulle proprie fotografie e sui propri post sui social, no dai.
L’auto-like sulle proprie fotografie e sui propri post sui social, no dai.
Oltre al semplice NET USE, in PowerShell è possibile usare il ComObject “WScript.Network” per gestire la mappatura di un disco di rete (map network drive).
Questo semplice script serve per mappare un disco di rete e per rimuovere la mappatura:
Write-Host "] Mapping Network Drive . . ." # Credentials $serverName = 'TESTPC01' $userName = 'TESTPC01\Administrator' $serverPwdSec = Read-Host -assecurestring "] Server password" # Ask for the user password $serverPwd = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($serverPwdSec)) $network = New-Object -ComObject WScript.Network try { # Previous method: NET USE T: \\$serverName\folderTest /USER:$userName $serverPwd $network.MapNetworkDrive("T:", "\\$serverName\folderTest", $false, "$userName", "$serverPwd") # $network.MapNetworkDrive("T:", "\\$serverName\folderTest") # Without credential Write-Host "] Network Drive mapped!`n" -BackgroundColor Green -ForegroundColor Black; } catch { Write-Host "[An error occurred in drive mapping!]" -BackgroundColor Red -ForegroundColor Black; Write-Host "[Error message:" $_.Exception.Message "`n" -BackgroundColor Red -ForegroundColor Black; }
Write-Host "] Remove Network Drive . . ." try { $network.RemoveNetworkDrive("T:") # Previous method: NET USE T: /delete } catch { Write-Host "[An error occurred in drive unmapping!]`n" -BackgroundColor Red -ForegroundColor Black; }
Se dopo aver lanciato yum update:
[usertest@fedoratest ~]$ sudo yum update
[sudo] password for usertest:
Compare:
Loaded plugins: langpacks, presto, refresh-packagekit
fedora/metalink | 33 kB 00:00
http://fedora.mirror.garr.it/mirrors/fedora/linux/releases/15/Everything/i386/os/repodata/repomd.xml: [Errno 14] curl#56 - "Network error recv()"
Trying other mirror.
ftp://ftp.ciril.fr/pub/linux/fedora/linux/releases/15/Everything/i386/os/repodata/repomd.xml: [Errno 14] curl#7 - "Couldn't connect"
Trying other mirror.
http://mirror.nl.leaseweb.net/fedora/linux/releases/15/Everything/i386/os/repodata/repomd.xml: [Errno 14] curl#56 - "Network error recv()"
Trying other mirror.
[...]
Potrebbe essere necessario impostare il vostro proxy nel file yum.conf. Quindi andiamo ad editare tale file:
[usertest@fedoratest ~]$ sudo gedit /etc/yum.conf
e aggiungiamo le seguenti righe al suo interno, dopo il tag [main]:
proxy=http://proxy.mioDominio.it:portaDelProxy
proxy_username=nomeUtente
proxy_password=miaPassword
Es:
[main]
proxy=http://proxy.gabriele.it:8080
proxy_username=gabriele
proxy_password=My_V3rY_Str0Ng_P4$$wW0rD!
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
...
N.B. 1: ricordatevi che il file yum.conf è aperto in lettura a tutti gli utenti… la password è scritta in chiaro…
N.B. 2: a quanto parte Fedora Core 15 ha un bug per l’impostazione del proxy. Leggi qui.