Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all 15028 articles
Browse latest View live

Rename-NetAdapter : {Object Exists} An attempt was made to create an object and the object name already existed.

$
0
0

Hi,

I'm currently having issues with renaming a network adapter, i'm trying to rename an adapter to the work 'MAIN' i've tried many different options for example this one i tried this.

https://superuser.com/questions/1267288/network-name-assigned-to-non-existent-object

And also a few other GUID fixes but for some reason this name is out there and i've even went a ahead and wiped the whole registry and still it remains.

Any idea?

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

PS C:\WINDOWS\system32> Get-NetAdapter

Name                      InterfaceDescription                    ifIndex Status       MacAddress        LinkS
                                                                                                          peed
----                      --------------------                    ------- ------       ----------        -----
Ethernet 2                Realtek PCIe GBE Family Controller #8        10 Disconnected 74-DA-38-C2-3E-32 0 bps
Ethernet                  Realtek PCIe GBE Family Controller #9         7 Up           2C-4D-54-D8-7D-4F ...ps


PS C:\WINDOWS\system32> Get-NetAdapter -Name Ethernet | Rename-NetAdapter -NewName MAIN
Rename-NetAdapter : {Object Exists} An attempt was made to create an object and the object name already
existed.
At line:1 char:33+ Get-NetAdapter -Name Ethernet | Rename-NetAdapter -NewName MAIN+                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo          : ResourceExists: (MSFT_NetAdapter... = "1234-i5-1"):ROOT/StandardCimv2/MSFT_NetA
   dapter) [Rename-NetAdapter], CimException+ FullyQualifiedErrorId : Windows System Error 698,Rename-NetAdapter



Read Computername and export certain value of it to a file

$
0
0

Hi guys,

I have a certain amount of computers that have all this syntax: NI020P-NIC-YXXX where "XXX" is the number that identifies the computer. I am looking for assistance in creating a VBS script that'll read the computername off of it and append the last 3 digits to a file that has this info:

<UPCSettings>
  <myPhoneNumber value="9990005078026xxx" />
</UPCSettings>

Where "xxx" should be the same number read off of the computername.

Might be simple, or not... but I have no clue on how to do it. Any help is appreciated.

Thanks,




Logoff/Shutdown script not executing

$
0
0

Hello,

I have 2 separate VBS scripts for appendig log on and log off times to the text file and set them to run on log on and log off via gpedit.msc on Windows 7 workstation. While Log on script runs just fine, log off script seems not executing on log off/shutdown.

Both scripts runs correctly when executed manually.

Could anyone tell me, why is my log off script not executing on log off?

Thank you.


How to format date in a Powershell command

$
0
0

Hi,

I try to get the install date of installed software correctly. My command hat the date output not correctly as follow. How can I list "InstallDate" correctly in formatDD.MM.YYYY?

PS> Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | select DisplayName, InstallDate |Sort-Object InstallDate -descend

Output:

DisplayName                                             InstallDate
-----------                                             ------------
Smart Storage Administrator CLI                         20171212
Microsoft Silverlight                                   20171206

Best regards

Birdal

Application installation

$
0
0
Hi experts please help me as i am trying to write a script to install and uninstall an application

I have folder by name MyApp1 and it has folders and sub folder, i want to copy this on C drive 
on all servers . i have shared it on a server, i want to push the script through sccm(for servers i will get through device collection)

@echo off
echo Starting app agent installation Script

net use y: "\\server01\MyApp1"
xcopy y:\ "C:" /y

for 64bit operating system
echo Installing App agent service
cd C:\Myapp1\win64
myapp.exe --config c:\MyApp1\agent.conf --install
net start "App agent"

for 32bit operating system
echo Installing App agent service
cd C:\Myapp1\win32
myapp.exe  --config c:\MyApp1\agent.conf --install
net start "App agent"

want to add one port 8080 to inbound rule also

==========================================
for uninstalling 

net stop "App agent"
sc delete "App agent"
Delete the folder C:\Myapp1 (all folders and subfolders in Myapp1)


Powershell - How to list GPO Settings

$
0
0

Hi 

I have problem to run PowerShell cmdlet, 

Get-GPResultantSetOfPolicy

That I have trying to get; 

*************************************************************************

  • GPO Report for default user

Get-GPResultantSetOfPolicy -ReportType Xml -Path "c:\scripts\LocalUserAndComputerReport.xml"

  • GPO Report for Computer

Get-GPResultantSetOfPolicy -ReportType Xml -Computer "computer-08.contso.com" -Path "c:\scripts\computer-08.xml"

  • GPO Report for specified User

Get-GPResultantSetofPolicy -User "Contoso\PattiFul" -ReportType Html -Path "c:\scripts\UserReport.html"

***************************************************************************

Get-GPResultantSetOfPolicy: The term 'Get-GPResultantSetOfPolicy' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

If it something I have missed, get permission or something?

Sokoban ;-) Please help



----- S-O-K-O-B-A-N -----




How to Run Batch File

$
0
0

Hi, I have a Program called unlock downloaded from below web site.

https://www.joeware.net/freetools/tools/unlock/index.htm

Now I just use it manually by the below method.

Copied Unlock file on C Drive


Now to Unlock account following is the method adopted

To View Locked Account Just use "l" and to unlock "u" (Run Batch Files as mention above) 

Need Help : 

I want to run l batch file to run after some interval using tasks scheduler how can I run this batch file please help.



PowerShell ISE -- Update-Help fails for WindowsUpdateProvider

$
0
0
update-help : Failed to update Help for the module(s) 'WindowsUpdateProvider' with UI culture(s) {nl-NL
} : Unable to retrieve the HelpInfo XML file for UI culture nl-NL. Make sure the HelpInfoUri property i
n the module manifest is valid or check your network connection and then try the command again.
At line:1 char:1
+ update-help
+ ~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (:) [Update-Help], Exception
    + FullyQualifiedErrorId : UnableToRetrieveHelpInfoXml,Microsoft.PowerShell.Commands.UpdateHelpComm
   and


Is there a solution for this problem?

Filter command not working

$
0
0

Hi Im trying to return some Exchange tracking logs - minus a few connector IDs.  I've added a filter as below but its completely ignored.  Any idea why?

Get-MessageTrackingLog -Start (Get-Date).AddHours(-24) -ResultSize unlimited | Select-Object eventid,messageid,sender,ReturnPath,timestamp,connectorid,@{Name="ClientIp";Expression={$_.ClientIp}},@{Name="Recipients";Expression={$_.recipients}},@{Name="RecipientStatus";Expression={$_.recipientstatus}},messagesubject | where {($_.ConnectorId -notlike "" -or $_.ConnectorId -notlike "SMTP Send Connector") -and ($_.ConnectorId -notlike "servercd201" -or $_.ConnectorId -notlike "serverd101") -and ($_.ConnectorId -notlike "Websense Send" -or $_.ConnectorId -notlike "Websense")} | sort connectorid | Export-csv c:\temp\ConnectorStats.csv -nti

Pin-App "ALIAS" -unpin | Some apps cannot be unpinned w/ this CMDLET

$
0
0

I do not know if this is by design OR a flaw in the CMDLET itself OR the CMDLET is going by a different name than what is being presented in the start menu (sometimes).

I've attempted to run the CMDLET to show all installs apps with their GUID and App Names, but even when I go by the app name from that result...still no cigar - it's not all apps, and I can't seem to determine what differentiates an app that can be unpinned by this CMDLET vs an app that cannot be unpinned by this CMDLET.

I've noticed that the Pin-App "ALIAS/NAME" -unpin does NOT unpin just any app, and I have yet to completely determine the rhyme or reason. I've read in other threads that the CMDLET only works for "INSTALLED" apps; I've proven this wrong as the CMDLET is unable to -unpin the Microsoft Whiteboard app which is a natively installed app of Windows 10. Maybe the app doesn't work for natively installed apps or "links".

I tried to include a picture below for reference/example of what I'm referring to, but my account needs to be "verified".

Thoughts?

How to check if a specific AD account belongs to a AD group from list?

$
0
0

Hello All!

I'm wondering if there is a powershell script to check a specific account from belongs to a certains groups (list of groups in CSV format). For the purpose of my lab the following command sequence does not works for that.

Get-ADPrincipalGroupMembership -identity user1 | select samaccountname

The idea is to make the inverse, export all groups of the domain and check if the user belongs to them. Why? the reason is the user is not member of the domain where the groups are.

I hope you can give me a hand, thank you in advance.

Sending results to a Txt or CSV file

$
0
0

Ran the below Script, not having much luck in getting all the output seen on the Screen into a File.  Any help, greatly appreciated.  Thanks.

$OUS = Get-ADOrganizationalUnit -Filter {name -like "*"} | select -expandproperty distinguishedname
foreach ($OU in $OUS){
$counter = 0
$gpos = Get-GPInheritance -target "$OU" |select -ExpandProperty inheritedgpolinks
foreach ($gpo in $gpos){
$counter++ 
$gponame = $gpo.displayname
"$counter","$gponame","$OU"
}
}

Log Output

$
0
0

Looking for a way to output the following Exchange code to a csv file, running into some issues along the way. The following code reads in all servers with Transport Service to scan all message tracking logs, then loops through them with the input. I am only concerned with SEND and DELIVER here, no other event ID's.


$servers = Get-TransportService | select -ExpandProperty Name
foreach ($server in $servers)
{
   Get-MessageTrackingLog -Server $server -Sender user@company.com -Start 2/22/2019 -End 2/26/2019 -ResultSize Unlimited | where {$_.eventid -eq "SEND" -or $_.eventid -eq "DELIVER"}
}

What I would like to do is take the final output of this command and feed it to a csv file. The loop is making this a bit tricky.

Back to menu after selection.

$
0
0

Hello,

This must be very simple, but im not be able to get it.

Function Show-Menu
{
    param (
        [string]$Title = 'Script Options'
    )
    Clear-Host
	Write-Host "============== $Title =============="
	Write-Host " 1 "
	Write-Host " 2 "
	Write-Host " 3 "
    Write-Host " 4 "
    Write-Host " 0 > Press '0' to cancel "
	}
Show-Menu
$selection = Read-Host "Please make a selection"

		
Function1
Function2
Function3
Function4

#Goodbye Message Function
Function exit {
Return
}

switch ($selection) {
    1 {Function1}		
		
	2 {Function2}
	
	3 {Function3}
		
	4 {Function4}
			
	0 {Exit}
}

I just  need back to menu when the selected Function (1,2,3 or 4) ends.

I try call again function menu with "Show-menu" after the last } but it doesnt work.

Thanks



WPF CheckBox IsChecked

$
0
0

Hi Everyone, 

I have a WPF GUI with a checkbox and a button. When I press the button, I want it to check if the checkbox is checked or not.

I have tried the following code but to no avail:

$syncHash.Button.Add_Click({

if ($syncHash.Checkbox.IsChecked){} if ($syncHash.Checkbox.Checked){}

})

In fact, nothing is showing up under the .isChecked option whilst running the script.

Can anyone shed a little light on this for me?

Thank you :) 



Change registry entry based on computer name

$
0
0

Im trying to figure out a script to change a registry key based on the computer name.

For example: If computer name contains FLH in the name, set registry HKLM\System\CurrentControlSet\Services\Spooler\Image to %systemroot%\System32\image\test

Is this possible? 

Searching the Arposh New User Creation Tool for Active Directory

$
0
0

Hi Guys.


I am searching the "Arposh New User Creation Tool for Active Directory". Can someon provide me the Download Link.

The following Link does not work anymore: http://gallery.technet.microsoft.com/scriptcenter/New-User-Creation-tool-14fa73cd

Greetings,

Peter

Variable binding error for Set-Service cmdlet

$
0
0

Hello,

When I execute the following command from a script

invoke-command -<g class="gr_ gr_90 gr-alert gr_spell gr_inline_cards gr_disable_anim_appear ContextualSpelling" data-gr-id="90" id="90">computername</g> $Servername -ScriptBlock {Set-Service -Name $name -Status Running} -Credential $MyCredentials

I get the following error:

Cannot bind argument to parameter 'Name' because it is null.

    + CategoryInfo          : InvalidData: (:) [Set-Service], ParameterBindingValidationException

    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.SetServiceCommand

    + PSComputerName        : xxxxxxxxx

 

Variables $name has a value ( I print the variable $name just before executing the command) of the service that I want to start on $Servername. If I remover the variable and hard code the service name it works. So, I know it's not an access issue. 

Any guidance will be appreciated!

-Jai

 

Question about the Get-DnsClientCache Section property

$
0
0

I noticed when parsing output from Get-DnsClientCache in PowerShell 4 is that the command displays the "Section" values inconsistently.  Using 'Get-DnsClientCache' will display the 'Section' property as a string (such as 'Answer'), where 'Get-DnsClientCache | Select Section' will display it as an integer (such as '1').

I wasn't able to find the answer through PowerShell help or googling.  I did notice that the mousing over the Intellisense prompt in the ISE lists the property as type 'Byte', so I assume that the command is automatically converting it for display. Per TechNet, the Section parameter will accept Answer, Authority, or Additional, and I've found that '0' is returned for records with status of 'NotExist' and that '1' is returned for 'Answer' records.  Does anyone know which numbers correspond to Authority and Additional?

Powershell Script to collect the list of software installed in a system

$
0
0

I need a Powershell script which will read the computer names from a text file and list the software installed on the computer and export it to a csv file. Output should be "Computer name" and "Softwares".

Can anyone help me on this ?

Viewing all 15028 articles
Browse latest View live